Word VBA - Put variable in clipboard

Why does this not work? Specifically, why do I get the error "Compile Error: User-Defined type not defined" with the phrase "New DataObject: highlighted when I try to run this in Word 2003?

Sub FullFilename()
    Dim currname As String
    Dim myData As Object
    Set myData = New DataObject
    currname = ActiveDocument.fullname
    myData.SetText curname
    myData.putinclipboard
    MsgBox currname
End Sub
GrayStricklandAsked:
Who is Participating?
 
Chris BottomleyConnect With a Mentor Software Quality Lead EngineerCommented:
Since you are relating VBA code you will be familiar with the editor : The Visual BAsic Editor or VBE.

On the Tools menu select references, (no macro should be running for this to be selectable).
In the references box navigate around to see if the microsoft forms library is visible, if it then simply select it.  If however it isn't visible then select browse and now navigate to the file called FM20.DLL (which will relate to MS forms library 2.0 and select open.  The MS forms 2.0 library should be automatically checked now so exit the box and retry your macro.

Chris
0
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Hello GrayStrickland,

YOu have one type for starters, corrected below.

Also to resolve the dataobject.  Add a ref to the forms library.  In teh VBE select tools references and the microsoft forms library (2.0 at a guess).  If it isn't there then browse for fm20.dll and add that.  Hopefully that will sort you out.

Regards,
Chris
Sub FullFilename()
    Dim currname As String
    Dim myData As Object
    Set myData = New DataObject
    currname = ActiveDocument.FullName
    myData.SetText currname
    myData.putinclipboard
    MsgBox currname
End Sub

Open in new window

0
 
GrayStricklandAuthor Commented:
"Also to resolve the dataobject, add a ref to the forms library.  In the VBE select tools references and the Microsoft forms library (2.0 at a guess).  If it isn't there then browse for fm20.dll and add that."

I have NO CLUE what you're saying.
0
 
GrayStricklandAuthor Commented:
Bravo!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.