Weird Behavior with VB and Word
Posted on 2002-03-12
I'm opening up a word template(.dot) from VB, populating some bookmarks and then running a macro. The macro actually populates the document itself. The first time I run this it works fine. Everything gets populated. However, when I run it a second time I get and error: The remote server machine does not exist or is unavailable.
My code is simple:
Dim oWord as Word.Application
Set oWord = new Word.Application
.Documents.Add (WORKING_DIR & "\templates\" & location)
.Visible = True
If .ActiveDocument.Bookmarks.Exists("bkFiscalYear") Then
Set oWord = nothing
it always seems to bomb on the selection.typetext part.
Does anyone have a clue as to what is going on? It only happens the 2nd time I run it.