Re: How can I copy text to clipboard using VB?

  • Thread starter Thread starter John Nurick
  • Start date Start date
J

John Nurick

Hi John,

try something like this air code

Dim D As MSForms.DataObject

Set D = New MSForms.DataObject
D.SetText Nz(Me.txtMyTextBox.Value, "")
D.PutInClipboard
Set D = Nothing
 
There's a runcommand constant for this. acCopy, acCmdCopy, or somesuch. (I
don't have Access here to check).

HTH,
TC
 
John Nurick said:
But that just copies the current selection, allee samee Ctrl-C.

Sorry: I didn't read the thread. All I saw was TC's comment about a
RunCommand constant.

I'll back out of here now...
 
Douglas J. Steele said:
Sorry: I didn't read the thread. All I saw was TC's comment about a
RunCommand constant.

I'll back out of here now...

Not at all!

My solution clearly assumed that the code would select the content of the
textbox first.

txtBlah.selstart=0
txtBlah.sellength=32000
docmd.runcommand accopy

Cheers,
TC
 
My solution clearly assumed that the code would select the content of the
textbox first.

txtBlah.selstart=0
txtBlah.sellength=32000
docmd.runcommand accopy

It's bad manners to change the selection.
 
John Nurick said:
It's bad manners to change the selection.


Note the current selection, change it, do the copy, then change it back!
The user wouldn't even see it happen.

Cheers,
TC
 
Back
Top