Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Mar 2008
    Location
    Frederick, Maryland, USA
    Posts
    16
    Thanks
    0
    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.

    Thanks
    Attached Files Attached Files

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 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 Normal.dot 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...

  4. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 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

    or

    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
  •