The information in this article applies to:
SYMPTOMSWhen you create a Visual Basic for Applications macro that calls Visual Basic for Applications commands for Word from another program, such as Microsoft Excel or Microsoft PowerPoint, you may receive the following error message:
CAUSE
This problem may occur when you dimension the Word Object variable as
Application.
WORKAROUND
Microsoft provides examples of Visual Basic for Applications procedures 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. The Visual Basic procedures in this article are
provided 'as is' and Microsoft does not guarantee that they can be used in
all situations. While Microsoft support professionals can help explain the
functionality of a particular macro, they will not modify these examples to
provide added functionality, nor will they help you construct macros to
meet your specific needs. If you have limited programming experience, you
may want to consult one of the Microsoft Solution Providers. Solution
Providers offer a wide range of fee-based services, including creating
custom macros. For more information about Microsoft Solution Providers,
call Microsoft Customer Information Service at (800) 426-9400.
Method 1: Dimension the Word Object Variable as ObjectYou can dimension the Word Object variable as an Object type. For example, use the following macro:
Method 2: Add the Word 8.0 Object Library ReferenceYou can add a reference to the Word 8.0 Object Library and use one of the following examples to call the Visual Basic for Applications commands for Word.Sample Macro That Creates a New Instance of Word: The following sample macro uses the New keyword to create a new instance of Word, adds a new document, inserts text, saves the document, and then quits the new instance of Word:
NOTE: You must use the Quit method before the macro is finished or the Word
instance remains in memory. Setting the object reference equal to Nothing
does not remove the instance of Word from memory. However, setting the
Object reference equal to Nothing frees the referenced object from memory.
Microsoft recommends that you use both statements together to clear memory
when the macro is finished.
Sample Macro That Uses the Existing Instance of Word: If Word is already running and you want to use the existing instance of Word, use the following sample macro:
To add the Word 8.0 Object Library from Microsoft Excel, Microsoft
PowerPoint, or Microsoft Access, use the following steps:
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. Additional query words: wordcon word8 word97 xlvbainfo 8.00 8.0 vb vba vbe
Keywords : kbinterop kbprg |
Last Reviewed: November 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |