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

How to open Word Template from VB6

Status
Not open for further replies.

JimFromLasVegas

Programmer
May 29, 2006
4
US
My VB6 model needs to open a template with bookmarks. Data is then placed in the appropriate bookmarks. User finally chooses whether to SaveAs or discard doc. Problem is VB can't find the *.dot file. I have tried over a dozen approaches and nothing seems to work. VB looks where it is suppose to look, the *.dot file is there but I get an error saying file cannot be found.

I have tried this:

Private Sub Command1_Click()

Dim wdMyApp As Word.Application
Dim wdMyDoc As Word.Document

Set wdMyApp = New Word.Application

Set wdMyDoc = wdMyApp.Documents.Open("C:\invoicetemplate.dot")

wdMyApp.Documents(wdMyDoc).Activate 'Make the word doc Active

Set wdMyApp = Nothing
Set wdMyDoc = Nothing
End Sub

I have placed a file invoicetemplate.doc in the same location as the .dot file. If I change the above code to invoicetemplate.doc it opens. I change back to invoicetemplate.dot and I get "This file could not be found." What am I doing wrong?

Merry Christmas from California
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top