View Single Post
  #6   Report Post  
Vic Spainhower
 
Posts: n/a
Default

Hi Cindy,

Thank you very much for the answer, I now have it resolved. I had already
done all of the things that you mentioned except the changing
"ActiveDocument" to WordDoc and I was still getting the error. After this
final change it now works correctly.

I use this same code in VBA and I've never had this problem. Why would that
be?

Thanks again Cindy!!

Vic



"Cindy M -WordMVP-" wrote in message
news:VA.0000a3a0.0098cc55@speedy...
Hi Vic,

I am trying to do a Mail Mege with VB6 and MS Word 2002 which will work
fine
for the first one document. However, if I select ther merge document a
second time it blows on the OpenDataSource statement with the error "The
remote server machine does not exist or is unavailable". I found
several
instances of this on Google but unfortunately the solution was not
posted.

The usual cause for the message, in my experience, is that you haven't
"cleaned
up after yourself". Your code has left an orphaned pointer to something in
the
Word instance you were using, before, which is blocking the second
execution of
your code.

The first thing in your code I see that makes me wonder is:

Set oApp = CreateObject("Word.Application")

On Error GoTo ErrorHandler

Set WordApp = GetObject(, "Word.Application")

If you use CreateObject to set oApp you certainly don't need to set an
additional object variable (WordApp) using GetObject. Try

On Error GoTo ErrorHandler
Set WordApp = CreateObject("Word.Application")
Set WordDoc = 'etc.

Remove oApp from your declarations, and the Set to Nothing near the end.

Then: you've created a document (WordDoc) and made it into the main merge
document. Why do you then proceed to use ActiveDocument? Subsitute WordDoc
everywhere you've used ActiveDocument.

And lastly - and this is probably the cause of the problem - you need to
set
the object variables to nothing in the reverse order in which they were
instantiated. So put Set WordDoc = Nothing BEFORE Set WordApp = Nothing.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply
in the newsgroup and not by e-mail :-)