txtbox no right click copy menu available?

C

Craigm

I need to highlight the contents of a textbox and copy it to th
clipboard. Momentarily it will be pasted into another application a
the file name to save that applications file as.

I can drag the mouse and highlight the .Text. I can then Ctrl-c t
copy the text to the clipboard. Then I can Ctrl-V or left click th
mouse and paste the .Text and save the file.

I would like to right click the mouse and have it select and copy th
txtbox.Text to the clipboard automatically.

I must be missing something simple.

Thanks for your suggestions,

Craig
 
C

Craigm

http://www.cpearson.com/excel/clipboar.htm

I used his solution to make this work flawlessly.
------------------------------
Copying To The Clipboard

To access the Windows Clipboard from VBA, you must go through an
intermediate object of the DataObject type. If your VBA procedure will
be working with the clipboard, declare a NEW DataObject object with the
following statement.

Dim MyDataObj As New DataObject

The SetText method of the DataObject variable is used to store a text
string or numeric value in the variable For example:

MyDataObj.SetText "This Is A Text String" Or
MyDataObj.SetText 123.456

This sets the contents of MyDataObj to a value. To copy the contents
of the variable MyDataObj to the Windows clipboard, use the
PutInClipboard method .

MyDataObj.PutInClipboard


------------

Public Sub PutOnClipboard(Obj As Variant)
Dim MyDataObj As New DataObject
MyDataObj.SetText Format(Obj)
MyDataObj.PutInClipboard
End Sub


Public Function GetOffClipboard() As Variant
Dim MyDataObj As New DataObject
MyDataObj.GetFromClipboard
GetOffClipboard = MyDataObj.GetText()
End Function


Public Sub ClearClipboard()
Dim MyDataObj As New DataObject
MyDataObj.SetText ""
MyDataObj.PutInClipboard
End Sub
 

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