Copy Text to clipboard.

pekajo

Registered User.
Local time
Today, 13:29
Joined
Jul 25, 2011
Messages
134
Hi,
I am trying to copy text to clipboard. The only way I have seen is by using focus method
Me!txtNotes.SetFocus
DoCmd.RunCommand acCmdCopy

is there a way of just copying some text ie "17856799"
The reason is that our printer requires a code to print and I do not want to have to type the code everytime so I can use Ctrl + V


Thanks for any help
 
so far as I know, that is the only way to copy to clipboard.

if you are using vba code perhaps you can assign the value as a parameter to the printer?
 
Hi. If nothing else, you should be able to put the code in a field or textbox and then copy it using VBA.
 
I’ve got a way but needs reference.
When I get to my computer I’ll post it. Give me 10 minutes.


Sent from my iPhone using Tapatalk
 
Here you go, hope this works as I run it using VBA in CorelDRAW, but imagine it should work across all.

Needs a reference set for Microsoft Forms 2.0 Object Library
If it's not in your Reference List, you can browse to it: C:\Windows\SysWow64\FM20.dll

Code:
Dim strText As String
Dim DataObj As New MSForms.DataObject

strText = Me.txtNotes

DataObj.SetText strText
DataObj.PutInClipboard
 
You can put this in the afterupdate event or you could code it to a button with "Copy Notes to Clipboard" as the caption, so people know what it does.

By using the after update event, when you tab out of txtNotes it copies.
 

Users who are viewing this thread

Back
Top Bottom