chrisgarvey
Technical User
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
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