XL98: Error Using GetObject to Activate Running Instance of Word (183102)



The information in this article applies to:

  • Microsoft Excel 98 Macintosh Edition

This article was previously published under Q183102

SYMPTOMS

When you use the GetObject function in a Microsoft Visual Basic for Applications macro to activate the running instance of Microsoft Word, you may receive the following error message:
Run-time error '429':
ActiveX component can't create object

CAUSE

This problem occurs if the following conditions are true:
  • An instance of Word has been started manually.

    -and-
  • No action has been taken in Word to load the Visual Basic for Applications library files into memory.

    The Visual Basic for Applications library files are loaded into memory if you do any of the following:
    • You run a macro.

      -or-
    • You run a wizard.

      -or-
    • You start the Visual Basic Editor.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around the problem, use the New keyword to create a new Word document, and then use the Parent property of that document to create a reference to the Word Application object.

Example

The following example uses Automation to control Word, if Word has already been started:
  1. Start Microsoft Excel.
  2. Start the Visual Basic Editor (press OPTION+F11).
  3. On the Tools menu, click References. Click to select the Microsoft Word 8.0 Object Library check box, and then click OK.
  4. On the Insert Menu, click Module.
  5. Type the following code in the module sheet:
          Sub Automate_Word()
    
             Dim WdApp as Word.Application
             Dim x As Word.Document
    
             ' Turn off error checking.
             On Error Resume Next
    
             ' Create a new Word document.
             Dim WdDoc As New Word.Document
    
             ' The following two lines of code allow you to hook into the
             ' Word Application object.
             Set Wdapp = WdDoc.Parent
             Set Wdapp = WdDoc.Parent
    
             ' Either one or two extra documents are opened by the two
             ' preceding lines of code. The following For Each loop closes the
             ' extra documents that are created by this subroutine. Any blank
             ' documents that have not been modified will be closed.
             For Each x in WdApp.Documents
                If x.Words.Count = 1 And x.Saved = True Then
                   x.Close False
                End If
             Next
    
             ' Display a message box that contains "Microsoft Word 8.0."
             MsgBox WdApp.Name & " " WdApp.Version
    
             ' Release the variables.
             Set WdApp = Nothing
             Set WdDoc = Nothing
          End Sub
    					
When you run the subroutine, a message box is displayed.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

REFERENCES

For more information about Automation, from the Visual Basic Editor, click the Office Assistant, type getobject, click Search, and then click to view "Working Across Applications."


Modification Type:MinorLast Reviewed:9/12/2006
Keywords:kbbug kberrmsg kbinterop kbpending KB183102