Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error: User Defined Type Not Defined

Status
Not open for further replies.

weigoldk

MIS
Jan 12, 2001
249
US
I'm trying to run a "simple" merge into MS word from a button on a form.

I get the following Error at line 3

Compile Error:
User-defined type not defined

1 Private Sub cmdMergeWord_Click()
2 On Error GoTo Err_cmdMergeWord_Click
3 Dim objWord As Word.Application

I have the following References selected in Tools
"Visual Basic for Applications"
"Microsoft Access 11.0 Object Library"
"OLE Automation"
"Microsoft DAO 3.6 Object Library"
"Microsoft ActiveX Data Objects 2.1 Library"
"Microsoft Office 11.0 Office Libray"
 
If you need to go early bound, you miss the reference to the Microsoft Word <version - 11?> Object Library

Roy-Vidar
 
I'm sorry--I should have also said I am very new to scripting.

I don't know if I need to go "early bound" or "late bound" or "on-time bound". I don't know what "bound" is or how I choose which way to go :).

 
If you add the reference, you'll be using early binding.

Roy-Vidar
 
Code:

Private Sub cmdPrtCCWWord_Click()
Call OpenWordDoc
End Sub


Public Function OpenWordDoc()
Dim objWord As Word.Application
End Function
 
Oops. I hit submit too quickly.

So, now I know I'm early binding.

How do I fix it--see my code above.
 
menu Tools -> References ...
tick the Microsoft Word 11.0 Object Library

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

Thanks for the reply. But like I said in the original post, I have the Microsoft Word 11.0 Object Library already included int he references.

 
But like I said in the original post, I have the Microsoft Word 11.0 Object Library already included int he references
Really ? Can you please reread carefully your own post ?
 
You caught me. The WORD library is not an option listed for me. I went out and checked the internet and found some evidence and feedback at other forums that the Office 11 library is a synonym for the Word 11 library.

I'm suspicious of that claim, but I haven't yet found a way to add in the Word library. Do you know how to add in that library?
 
I'm suspicious of that claim
Sure you should.

Do you have Word installed ?
If yes you may consider repair your msoffice install.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I have all of Office 2003 installed including Word. I'm getting the same error on at least two other computers both with Office 2003 installed.

I'll try a repair on my PC and let you know how it goes--I might not get to it today :(.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top