copy string to clipboard (1 Viewer)

cpampas

Registered User.
Local time
Today, 06:56
Joined
Jul 23, 2012
Messages
218
hello,
Is there a way to copy a string to the clipboard, and after that to be able to press the keys ctrl+V to paste it ?
 

kyforests

New member
Local time
Today, 09:56
Joined
May 19, 2023
Messages
2
hello,
Is there a way to copy a string to the clipboard, and after that to be able to press the keys ctrl+V to paste it ?
The code the theDBguy and GaP42 suggest works for me without issue. However, to use that code on my 64bit machines, I had to replace "Delcare Function" with "Declare PtrSafe Function". I also had to replace "long" with 'LongPtr". I can't say I understand why that is but that was the answer I found after not being able to make the original code work.

Good luck.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:56
Joined
Sep 21, 2011
Messages
14,306
A quick Google would reveal a lot of links, one of which would not be affected by the bitness of Access ?


Even if you are affected by the bug mentioned, the API version is also there, amended for bitness.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:56
Joined
Feb 19, 2013
Messages
16,614
However, to use that code on my 64bit machines
It is not because you have a 64bit machine but because you are using 64bit access.
 

cpampas

Registered User.
Local time
Today, 06:56
Joined
Jul 23, 2012
Messages
218
thank you all. I used the code Gasman suggested that works great
 

MarkK

bit cruncher
Local time
Today, 06:56
Joined
Mar 17, 2004
Messages
8,181
Code:
Sub WriteToWindowsClipboard(Text As String)
    ' uses a late bound MSForms.DataObject
    With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
        .SetText Text
        .PutInClipboard
    End With
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:56
Joined
Sep 21, 2011
Messages
14,306
Code:
Sub WriteToWindowsClipboard(Text As String)
    ' uses a late bound MSForms.DataObject
    With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
        .SetText Text
        .PutInClipboard
    End With
End Sub
@MarkK Does using the GUID remove the need to add the MS Forms library?
I had to add it it to test that code and then move it up the hierarchy for the code to work.
 

MarkK

bit cruncher
Local time
Today, 06:56
Joined
Mar 17, 2004
Messages
8,181
Yeah, that code I posted should work as is, no need for any references.
 

Users who are viewing this thread

Top Bottom