Remote server machine does not exist

K

Ken Kisiel

I have a VB6 application that starts MS Word and creates a
document. This document contains a Table of Contents and
other text. The first time I call the creation process,
everything works fine. If I close Word and call the
creation routine a second time, I get a 'Remote server
machine does not exist or is unavailable' message. If I
restart my VB app or remove the creation of the TOC it
works fine without restarting my app. Same thing happens
with inserting an image.

Anyone have any thoughts on what's happening and how to
prevent it?

Thanks
Ken
 
J

Jezebel

You get that message if you try to use the properties or methods of a Word
application object after you've closed Word, eg ...

set pWordApp = new Word.Application
pWordApp.Documents.Open(FirstDocument)
..... do whatever ...
pWordApp.Quit

**** At this point pWordApp points to a closed Word application. It's not
nothing, but you can't use it ****

if not pWordApp is nothing then
pWordApp.Documents.Open(SecondDocument) <----- this will fail
end if
 
J

JGM

Hi Ken,

I have seen this and banged my head on a wall for three days...

Can you post the full "TOC" line so that I can see if it is similar to the
situation I had, in which case my solution might work for you.

Cheers!
 
J

Jezebel

After you've run the routine once and gone past the WordApp.quit, check the
task manager and see if you still have an instance of Word running. Word is
fairly sensitive to errors triggered by external code, and its response is
sometimes to go off in a sulk and refuse to close, without giving any error
message but retaining (in some undefined sense) the error condition. Next
time you run your routine, your WordApp points to the *existing* instance of
Word, which persists with its error state, hence your code falls over next
time round.

Do you close your document, and if so do you check that it actually *has*
closed? When run via VB, you sometimes get a problem with this sequence --

pWordDoc.Save (or SaveAs etc)
pWordDoc.Close <---- Word sometimes stops and prompts to save changes,
although you've just done that.

Workarounds are to use Doc.Close SaveChanges:=TRUE, or set Doc.Saved = TRUE.
 
K

Ken Kisiel

JGM

Thanks for your help. Here is that actual TOC statement:

With Wrd.ActiveDocument
.TablesOfContents.Add
range:=Selection.range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True,
UpperHeadingLevel:=1, _
LowerHeadingLevel:=3,
IncludePageNumbers:=True, AddedStyles:=""
.TablesOfContents(1).TabLeader =
wdTabLeaderDots
End With

As I indicated in my last response, if I do not call this
statement, everything works fine regardless of the number
of times I create the document.

Thanks again,
Ken
 
J

JGM

Hi Ken,

I am not sure but I think I have got it:

Assuming that Wrd was declared as an Application, change

range:=Selection.range, RightAlignPageNumbers:= _

to

range:=Wrd.Selection.range, RightAlignPageNumbers:= _

When we code in Word for Word, we take many thigs for ganted, like the fact
that the Selection property does not have to be prefixed by an Applicaton or
Window object...

I had exactly the same problems with the InchesToPoints method, as it was to
the right of an equal sign , together with other parameters, it never
occured to me to prefix it with an Application object. When I did, problem
solved... Something to do with the internal memory reference that isn't
released unless it is specifcally allocated... There is a KB article on
this, but right now I do not have the time to look for it, sorry!

HTH
Cheers

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Ken Kisiel" <[email protected]> a écrit dans le message de [email protected]...
JGM

Thanks for your help. Here is that actual TOC statement:

With Wrd.ActiveDocument
.TablesOfContents.Add
range:=Selection.range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True,
UpperHeadingLevel:=1, _
LowerHeadingLevel:=3,
IncludePageNumbers:=True, AddedStyles:=""
.TablesOfContents(1).TabLeader =
wdTabLeaderDots
End With

As I indicated in my last response, if I do not call this
statement, everything works fine regardless of the number
of times I create the document.

Thanks again,
Ken
 
J

JGM

Hi again,

Got the reference... Here it is:

Go see the MS KB article for more info:
http://support.microsoft.com/default.aspx?scid=kb;en-us;189618

Cheers!
--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Ken Kisiel" <[email protected]> a écrit dans le message de [email protected]...
JGM

Thanks for your help. Here is that actual TOC statement:

With Wrd.ActiveDocument
.TablesOfContents.Add
range:=Selection.range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True,
UpperHeadingLevel:=1, _
LowerHeadingLevel:=3,
IncludePageNumbers:=True, AddedStyles:=""
.TablesOfContents(1).TabLeader =
wdTabLeaderDots
End With

As I indicated in my last response, if I do not call this
statement, everything works fine regardless of the number
of times I create the document.

Thanks again,
Ken
 
K

Ken Kisiel

That fixed it. Thanks for you help.

Ken

-----Original Message-----
Hi again,

Got the reference... Here it is:

Go see the MS KB article for more info:
http://support.microsoft.com/default.aspx?scid=kb;en- us;189618

Cheers!
--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Ken Kisiel" <[email protected]> a écrit dans le message de [email protected]...
JGM

Thanks for your help. Here is that actual TOC statement:

With Wrd.ActiveDocument
.TablesOfContents.Add
range:=Selection.range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True,
UpperHeadingLevel:=1, _
LowerHeadingLevel:=3,
IncludePageNumbers:=True, AddedStyles:=""
.TablesOfContents(1).TabLeader =
wdTabLeaderDots
End With

As I indicated in my last response, if I do not call this
statement, everything works fine regardless of the number
of times I create the document.

Thanks again,
Ken


.
 

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