Access 2000 & Word Bookmarks

G

Guest

Hi,

I wonder if anyone can help me. I have Access 2000
database that I have written to interact with word and
print letters and envelopes of contacts by using
predefined bookmarks in a word template. When the code is
first run it works fine, but on subsequent runs I receive
an error 462: the remote server machine is does not exist
or is unavailable. I have to quit Access & restart for it
to run once again. MS technical help does not help. The
code is below

With objWord
objWord.Documents.Add strWordTemplate

.ActiveDocument.Bookmarks("Name").Select
.Selection.Text = strName
ActiveDocument.Bookmarks.Add _
Name:="EnvelopeName", Range:=Selection.Range (Code
fails here)

.ActiveDocument.Bookmarks("Address").Select
.Selection.Text = strAddress
.ActiveDocument.Bookmarks.Add Name:="EnvelopeAddress",
Range:=Selection.Range


Thanks in advance

Stuart
 
B

Bill Taylor

I had the same problem once and resolved it by using fully qualified
references. That basically means all references must proceed from the
application object itself. (In your case objWord ) I found the solution in
Microsofts knowledge base. i.e. :
looks like the (.) is missing before ActiveDocument which would cause it to
fail the second time for the reason above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top