tags:

views:

47

answers:

1

When starting up Word from a form in Access, I do this:

   Dim wordApp As Word.Application
   Dim wordDoc As Word.Document
   Dim wordRange As Word.Range

   Set wordApp = CreateObject("Word.Application")

   wordApp.Visible = True
   Set wordDoc = wordApp.Documents.Open(etikettenTemplate)

   ' fill in some bookmarks in the word doc

   Set wordApp = Nothing
   Set wordDoc = Nothing
   Set wordRange = Nothing

The problem is: this runs fine the first time the code runs. The second time I get a runtime error 462: The remote server computer doesn't exist or is not available.

The trouble is, I can't control the whole cycle, as the user may need to edit the word doc before closing. Am I doing something wrong? Thanks for any suggestion

+1  A: 

Sorry, have been able to solve the problem myself.

The error was that I was accessing the bookmarks of the doc through

ActiveDocument.Bookmarks(mybookmark).Range

instead of the previously chosen wordDoc variable

By changing all occurences of ActiveDocument with wordDoc the problem vanished.

Thanks to all anyway

fablife
+1 for getting back with a solution.
Remou