VBA Runtime error 462

N

Newbie

Hello,
I have 2 VBA procedures which create a Word document from 2 different
templates : Model1 or Model2, stored in the same directory:
Set wrdDoc = Documents.Add(Template:="\\Server\Mes documents
SVR\Pilotage\Model1.dot", Visible:=False)
The 2 procedures ran many times without any problem, but today one of them
generates the error message:

"Runtime error '462'. The remote server doesn't exist or is not available."
What could be the cause of this error?
Thanks for your help!

Newbie
 
N

Newbie

Jezebel,

False : another procedure using the same syntax connects perfectly onto the
same server, on the same directory...
 
C

Cindy M.

Hi Newbie,
I have 2 VBA procedures which create a Word document from 2 different
templates : Model1 or Model2, stored in the same directory:
Set wrdDoc = Documents.Add(Template:="\\Server\Mes documents
SVR\Pilotage\Model1.dot", Visible:=False)
The 2 procedures ran many times without any problem, but today one of them
generates the error message:

"Runtime error '462'. The remote server doesn't exist or is not available."
What could be the cause of this error?
Often, this error means that a document variable you instantiated, to hold an
object, hasn't been released. Since it hasn't been released, when the VBA
code runs again, it can't re-use the object. Most often, this happens with an
object variable to which the application you're remoting is assigned.
Example:

Dim wdApp as Word.Application
Set wdApp = New Word.Application
'do things
End Sub

You'll notice that, in this code snippet you don't see
Set wdApp = Nothing

So the next time the code runs, there's a good chance the code will fail at
Set wdapp = New Word.Application.

Note that ANY "orphaned" pointer to an object could be causing the problem.
It could, for example, be wrdDoc in your code.

The next time you see the error, try closing the application in which your
code is running, then start it again. I'm betting the code will run the first
time after you re-start the application. Then you need to track down under
what particular set of circumstances this happens, follow that code branch,
and discover where the objects aren't being correctly released.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 

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