Error message received when accessing the clipboard using VBA

G

Ganeth

I'm looking to be able to access the clipboard contents using VBA. Here's some code which I got from this forum (guy name of Helmut posted it)

Sub R_clipboard_to_variable(

Selection.Cop

Dim o As DataObjec
Dim s As Strin
Set o = New DataObjec
o.GetFromClipboar
s = o.GetText(1
MsgBox

End Su

Now this doesn't really do a whole lot of anything, but the end result will have to do with re-writing the headers and footers of about 300 odd documents. When I run this code, though, I get a Compile Error: User-defined type not defined. As I understand it, the dataObject object should be integral to VBA and not something I have to declare a class for. My copy of VBA says it's version 6.3.8863. If anyone can shed any light on this (add-in needs installing, maybe?) then I'd be most obliged

Ganeth
 
P

Peter Hewett

Hi Ganeth

Try the following:

Sub R_clipboard_to_variable()
Dim o As MSForms.DataObject
Dim s As String

Selection.Copy

Set o = New MSForms.DataObject
o.GetFromClipboard
s = o.GetText(1)
MsgBox s
End Sub

HTH + Cheers - Peter
 
G

Ganeth

Thanks Peter,

I tried this, and still received the same error message. I think I need to check one of the 'References' under tools, but the .dll file which contains the dataobject object - fms20.dll - is not there. I'm going to try checking them all and see what happens.

Thanks again,

Ganeth
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

See the article “Manipulating the clipboard using VBA” at:

http://word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
G

Ganeth

Problem solved - The references dialogue box also allows you to browse for .dll files to reference - found fm20.dll in c:\windows\system32 and referenced it. Thanks for your help.

Ganeth
 
P

Peter Hewett

Hi Ganeth

So presumably you get an error when trying to insert a USerForm into your
project?

I'm not sure which version of Office you're using but the forms library is
normally called "FM20.dll".

Cheers - Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top