Putting plain text string into clipboard in VBA?

D

Don Wiss

Our pricing program produces a quote letter on a worksheet. All text is in
Column A. Right now I have a button that puts Column A into the clipboard,
then the user pastes it into Notes. The problem is Notes considers this a
picture, so the user has to select Paste Special -> Text from the menu to
paste in. Now the macro behind the button could easily turn the text in
Column A into a delimited text string. But then how would my VBA code put
that string into the clipboard?

Don <www.donwiss.com> (e-mail link at home page bottom).
 
V

Vasant Nanavati

Sorry, no brilliant ideas. Perhaps a MessageBox?

MsgBox "The data is now in the Clipboard and is ready to be pasted into
Notes.", vbOKOnly
 
K

keepITcool

you could do it via api's but msforms has a databoejct
you could use for this.

make sure you have a reference to msforms in your project

Sub Foo()
Dim s As String
Dim c As Range
Dim cb As MSForms.DataObject
Const DL = ";"

For Each c In Range("a1:a12")
s = s & DL & CStr(c)
Next

Set cb = New DataObject
cb.SetText Mid(s, 2)
cb.PutInClipboard
Set cb = Nothing

End Sub




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Don Wiss wrote :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top