Clipboard Question

Huey462

Board Regular
Joined
Jul 25, 2011
Messages
147
I'm trying to add a text string to the windows clipboard for easy copy/pasting between Access and a webpage. Seems straightforward enough but I can't find the correct reference to load the objects library in order to use the method below. Which would explain the "User-defined type not defined" error.

Code:
' Removes "-" from NSN string
Dim TempNSN As String
   TempNSN = Me.txtNSN.Value
   TempNSN = Replace(TempNSN, "-", "")
   'MsgBox TempNSN 'visually ensure dashes are gone
'Saves NSN to clipboard
' http://stackoverflow.com/questions/5552299/how-to-copy-to-clipboard-using-access-vba
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText TempNSN
clipboard.PutInClipboard

So, how can I tweak the code to circumvent the need to load the object database or what is the object reference called in Access 2010?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I don't use Access, but maybe try

Code:
Dim clipboard As Object
Set clipboard = CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
 
Upvote 0
Works beautifully, now how in the world did you figure out CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
 
Upvote 0
You're welcome.

Probably from Rory Archibald.
 
Upvote 0

Forum statistics

Threads
1,221,821
Messages
6,162,157
Members
451,750
Latest member
pnkundalia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top