Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Mar 2008
    Frederick, Maryland, USA
    Thanked 0 Times in 0 Posts

    Run-time error '462' (Word 2003)

    I am experiencing the following when I run my attached routine; it opens an instance of word - does some stuff and closes word. But, when it comes to opening the second word file, I get the following error:

    Run-time error '462':
    The remote server machine does not exist or is unavailable

    So, I have to go out and manually end the "Winword" process. I have tried to change the code based on web recommendations, but the error persists. Would someone look at the attached code to determine if I am doing something wrong.

    Attached Files Attached Files

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: Run-time error '462' (Word 2003)

    If you leave the application visible, can you see any prompts or other explanations for Word failing to quit? For example, there's a possibility that your changes to the document might be affecting an attached template or somehow.

    Even so, it seems you should be able to create another WinWord process if one is running... unless for some reason it has locked something that other instances also need. Hmmm...

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Run-time error '462' (Word 2003)

    When using Automation, i.e. when you control one application in code from another one, you must take great care to make *all* objects refer directly or indirectly to the Application object that you create. The line

    Set wdoc = objApp.Documents.Open(...)

    is fine, because the you explicitly specify that the Documents object belongs to objApp. But a line such as

    TotTbls = ActiveDocument.Tables.Count

    is dangerous, since ActiveDocument doesn't refer to objApp. It will probably cause a new instance of Word to be created, and this instance will remain in memory. It should either be

    TotTbls = wdoc.Tables.Count


    TotTbls = objApp.ActiveDocument.Tables.Count

    (The first form is preferable since it will even work if the document that you opened is not the active document anymore). Similarly, you should use objApp.Selection instead of Selection.

    Make sure that you apply this to all instances of ActiveDocument and Selection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts