Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-16-2019, 04:17 PM   #1
pekajo
Newly Registered User
 
Join Date: Jul 2011
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
pekajo is on a distinguished road
Copy Text to clipboard.

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

pekajo is offline   Reply With Quote
Old 09-16-2019, 04:45 PM   #2
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,333
Thanks: 40
Thanked 3,670 Times in 3,538 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Copy Text to clipboard.

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?
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 09-16-2019, 04:49 PM   #3
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,899
Thanks: 57
Thanked 1,289 Times in 1,270 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Copy Text to clipboard.

Hi. If nothing else, you should be able to put the code in a field or textbox and then copy it using VBA.

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 09-16-2019, 07:35 PM   #4
nhorton79
Newly Registered User
 
Join Date: Aug 2015
Posts: 108
Thanks: 12
Thanked 13 Times in 13 Posts
nhorton79 is on a distinguished road
Re: Copy Text to clipboard.

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 is offline   Reply With Quote
Old 09-16-2019, 07:57 PM   #5
nhorton79
Newly Registered User
 
Join Date: Aug 2015
Posts: 108
Thanks: 12
Thanked 13 Times in 13 Posts
nhorton79 is on a distinguished road
Re: Copy Text to clipboard.

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 is offline   Reply With Quote
Old 09-16-2019, 08:01 PM   #6
nhorton79
Newly Registered User
 
Join Date: Aug 2015
Posts: 108
Thanks: 12
Thanked 13 Times in 13 Posts
nhorton79 is on a distinguished road
Re: Copy Text to clipboard.

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.
nhorton79 is offline   Reply With Quote
Old 09-17-2019, 07:09 AM   #7
sxschech
Newly Registered User
 
Join Date: Mar 2010
Posts: 612
Thanks: 28
Thanked 112 Times in 101 Posts
sxschech is on a distinguished road
Re: Copy Text to clipboard.

Here is a link to documentation about it. The article also mentions how to use late binding. I have been using their late binding method.

Quote:
Late Binding to DataObject by CLSID
https://bytecomb.com/copy-and-paste-in-vba/


sxschech is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy field text to clipboard error randle Forms 4 09-10-2013 12:23 AM
Copy to Clipboard? theKruser Modules & VBA 16 09-09-2011 07:14 AM
Copy to Clipboard thingssocomplex Modules & VBA 7 01-14-2011 04:15 AM
[SOLVED] Copy text box Contents to clipboard Carriolan Modules & VBA 1 02-17-2006 08:24 AM
How to copy to clipboard DanR Modules & VBA 3 02-07-2003 05:42 PM




All times are GMT -8. The time now is 08:27 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World