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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User-defined type not defined - trying to export from VB to word 1

Status
Not open for further replies.

chrisgarvey

Technical User
Mar 27, 2003
64
0
0
GB
Can anyone tell me why when I run the code below, I get an error message 'compiler Error, user-defined type not defined'?

The program exports the contence of text boxes on a form to a MS Word document placing them using bookmarks.

I got the adapted code from an earlier post.

Many Thanks,

Chris

Private Sub Command1_Click()
Dim WordObject As Word.Application
Set WordObject = CreateObject("Word.Application")

With WordObject
.Documents.Open ("C:\Documents and Settings\OEM Student\Desktop\New Folder\JewelleryReport.doc")
.ActiveDocument.Bookmarks("transtype").Select
' reapply the boomark name to the selection
'.ActiveDocument.Bookmarks.Add Name:="First",Range:=Selection.Range

.ActiveDocument.Bookmarks("JewelleryItem").Select
.Selection.Text = (Text1.Text)
End With
WordObject.Visible = False
WordObject.ActiveDocument.PrintOut Background:=False
WordObject.ActiveDocument.SaveAs FileName:="C:\Documents and Settings\OEM Student\Desktop\New Folder\x.doc"
' setting the printing to background will display the document
' on the screen while it is being printed
' WordObject.Documents.Close '("c:\program files\qcap\transmove.doc")
WordObject.Application.Documents.Close
Set WordObject = Nothing

End Sub
 
Where do you get the error message, i.e. which line is highlighted?

At first sight, the code doesn't look bad.

Cheers,
Andy

[blue]The last voice we will hear before the world explodes will be that of an expert saying:
"This is technically impossible!" - Sir Peter Ustinov[/blue]
andreas.galambos@bowneglobal.de
HP:
 
Have you set a reference to Word in the Project|References list?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Thanks Johnwm.

I set a reference to word:

'Microsoft word 10.0 object library'

in the project references list, as you suggested.

Chris.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top