Share Button

The process to solve runtime error 462 is available for the all types of users here. Duration of running Microsoft visual basic code that use Automation for controlling Microsoft word, then the following error message may received by you.

Error message a
Run-time error ‘-2147023174’ (800706ba)
Automation error

Error message b
Run-time error ‘462’: The remote server machine does not exist or is unavailable

  • The most common reason behind this error is installing incompatible or outdated driver, missing system files, corrupted registry file or damaged pc by viruses. Advanced System Repair Tool is the only solution for all the system errors. By installing this tool you will be able to remove above windows error.
    3 Steps to Fix this Error

    Step 1. Download Advance System Repair Tool [File Size: 15.7 MB]
    Step 2. SCAN your Windows PC
    Step 3. Click Fix button to Repair Error

The both error message have the same reason and symptoms. The important fact is that the resolution for the both error message is also same.

Reasons of runtime error 462

A reference has established by visual basic for word due to a line of code that is used for call word object, method and property with a word object variable and without qualifying it. The reference does not released by visual basic until the ending of the program. The reference interferes with the automation code when the code runs more than one time and gives runtime error 462.

How to solve runtime error 462

You have to change the code by which each call to a word object, method and property that qualified with the exact object variable. Follow these steps to remove this error.

  • Open a new Standard EXE project in visual basic.
  • If you are using office word 2007 then click on Microsoft Word 12.0 Object Library, if you are using word 2003 then click on Microsoft Word 11.0 Object Library, if the version of word is 2000 then click on Microsoft Word 9.0 Object Library and click Microsoft Word 8.0 Object Library for Microsoft word 97.
  • In the default form 1 put a command button.
  • Now copy the following code in the code window of form 1.
  • Option Explicit

    Private Sub Command1_Click()
    Dim oWord As Word.Application
    Dim oDoc As Word.Document
    Dim oRange as Word.Range

    Set oWord = CreateObject(“Word.Application”)
    With oWord
    .Visible = True
    .Activate
    .WindowState = wdWindowStateNormal
    End With

    Set oDoc = oWord.Documents.Add
    MsgBox “Document open”, vbMsgBoxSetForeground
    With oDoc
    .PageSetup.LeftMargin = InchesToPoints(1.25)
    End With

    ‘ This example inserts text at the end of section one.
    Set oRange = ActiveDocument.Sections(1).Range
    With oRange
    .MoveEnd Unit:=wdCharacter, Count:= -1
    .Collapse Direction:=wdCollapseEnd
    .InsertParagraphAfter
    .InsertAfter “End of section.”
    End With

    With oDoc
    .Saved = True
    End With

    Set oRange = Nothing
    Set oDoc = Nothing
    oWord.Quit
    Set oWord = Nothing
    End Sub

    Click start or you can also press F5 for run the program. Then click on command button. You will see no error occurs and a reference to word has been created and also has not been released. After that stop the program and then change the following line in the program.

    .PageSetup.LeftMargin = InchesToPoints(1.25)
    To
    .PageSetup.LeftMargin = oWord.InchesToPoints(1.25)

    Again run the program and click on command button again no error you will receive. Now again click on the command button then you receive this error. now stop the program and change the following lines.

    Set oRange = ActiveDocument.Sections(1).Range
    To
    Set oRange = oWord.ActiveDocument.Sections(1).Range

    Now run the program again and again you will not get the runtime error 462.

    Share Button
    “Run-time error ‘462’” while running Visual Basic code that uses Automation to control Word

Leave a Reply

Your email address will not be published. Required fields are marked *