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

Word Automation Problem

Status
Not open for further replies.

Steve101

Programmer
Mar 29, 2002
1,473
AU
I have an Access 2000 application which uses Word automation to create a Word document from a Word template. All works well, except, when I run the program more than once, it fails with:

Runtime error 462: The remote server machine does not exist or is not available.

It always fails with the above error on the code line which reads:

With DocT
.TablesOfContents.Add Range:=Selection.Range, _
RightAlignPageNumbers:=True, _
UseHeadingStyles:=True, _
UpperHeadingLevel:=1, _
LowerHeadingLevel:=3, _
IncludePageNumbers:=True, _
AddedStyles:="", _
UseHyperlinks:=True, _
HidePageNumbersInWeb:=True
...
... other stuff
...
End With

If I leave this code out (which generates the table of contents), then everything works OK; ie. the program is re-runnable, produces the required Word document, but alas, no table of contents!! With this code in, I have to shut down the program after running it once.

Does anyone have any way of handling this situation; possibly re-coding the table of contents code to avoid this situation.

Is there anything I can do up top when the Word application and documents are defined and instantiated which would help.

Any help would be greatly appreciated,

Cheers,
Steve
 
Thanks John; doing all of that, but unfortunately it doesnt help. Really doesnt seem to like that TOC stuff.
Cheers,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top