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

Automate Word Doc

Status
Not open for further replies.

thankgodfortektips

Programmer
Dec 20, 2005
95
KY
Guys,

I have been looking at this all damn day... I have 2 sets of code that kind of work. I have one that open a rtf file and the next that loops through docVariables. The docVariable is the preferred method because the user needs .doc not .rtf.

here is the code...
************************************
Set WordApp = Server.CreateObject("Word.Application")
Set WordDoc = Server.CreateObject("Word.Document")
Set WordDoc = WordApp.Documents.Open("D:\doc1.doc")
With WordDoc
.Variables("strSurname").Value = "test1"
.Variables("strMaidenName").Value = "test2"

'On Error Resume Next
.Fields.Update
.SaveAs "D:\test1.doc"
.Close
'On Error Goto 0
End With
WordApp.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
*******************************

This code is working apart from the fact that when I load test1.doc I have to go to the field and right click on it and say update field... I would think that .fields.update would do this for me... Anyone any ideas?

thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top