• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 938
  • Last Modified:

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
0
GrayStrickland
Asked:
GrayStrickland
  • 2
  • 2
1 Solution
 
Chris BottomleyCommented:
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
 
Chris BottomleyCommented:
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
 
GrayStricklandAuthor Commented:
Bravo!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now