XL98: Error Using GetObject to Activate Running Instance of Word

ID: Q183102


The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition


SYMPTOMS

When you use the GetObject function in a Visual Basic for Applications macro to activate the running instance of Microsoft Word 98 Macintosh Edition, 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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft Support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
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 98 Macintosh Edition.


  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 into 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 this to be a problem in the Microsoft products listed at the beginning of this article.


REFERENCES

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

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

Q179216 OFF98: How to Use the Microsoft Office Installer Program

Additional query words: XL98 ole

Keywords : kberrmsg kbinterop kbdta xlvbainfo AutoGnrl offinterop
Version : MACINTOSH:98
Platform : MACINTOSH
Issue type : kbbug


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.