Copy Text to clipboard. (1 Viewer)

pekajo

Registered User.
Local time
Tomorrow, 07:23
Joined
Jul 25, 2011
Messages
132
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
 

CJ_London

Super Moderator
Staff member
Local time
Today, 20:23
Joined
Feb 19, 2013
Messages
16,553
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?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:23
Joined
Oct 29, 2018
Messages
21,358
Hi. If nothing else, you should be able to put the code in a field or textbox and then copy it using VBA.
 

nhorton79

Registered User.
Local time
Tomorrow, 09:23
Joined
Aug 17, 2015
Messages
147
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
 

nhorton79

Registered User.
Local time
Tomorrow, 09:23
Joined
Aug 17, 2015
Messages
147
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
 

nhorton79

Registered User.
Local time
Tomorrow, 09:23
Joined
Aug 17, 2015
Messages
147
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

Top Bottom