The information in this article applies to:
SYMPTOMSWhen you run code in a Microsoft Visual Basic version 3.0 application and the code uses a method or property of an object linking and embedding (OLE) automation object, you may receive the following error message
CAUSESome of the methods and properties of OLE Automation objects are keywords in Visual Basic version 3.0 and will cause the error message above when you use them in a Visual Basic application. WORKAROUNDTo use a method or property of a Microsoft Excel object in a Visual Basic application when the method or property is a Visual Basic keyword, use square brackets ([]) around the keyword in the Visual Basic code. For example, to use the Close method of the Microsoft Excel Workbooks object in a Visual Basic application, use the following syntax: XL.Workbooks(1).[close] MORE INFORMATION
OLE Automation is an industry standard that applications use to expose OLE
objects to development tools, macro languages, and other containers that
support OLE Automation. A few of the objects exposed by Microsoft Excel are
workbooks, worksheets, and charts. These objects can be accessed with
Visual Basic commands.
Steps to Reproduce BehaviorMicrosoft provides examples of Visual Basic 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. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose. Note that a line that is preceded by an apostrophe introduces a comment in the code--comments are provided to explain what the code is doing at a particular point in the procedure. Note also that an underscore character (_) indicates that code continues from one line to the next. You can type lines that contain this character as one logical line or you can divide the lines of code and include the line continuation character. For more information about Visual Basic for Applications programming style, see the "Programming Style in This Manual" section in the "Document Conventions" section of the "Visual Basic User's Guide.
even though Close is a method of the Microsoft Excel Workbooks object. To make this piece of code work correctly, change the last line to: xl.ActiveWorkbook.[Close] REFERENCESFor more information about the GetObject Function, choose the Search button in Microsoft Visual Basic Help and type: OLE Automation Additional query words:
Keywords : kbprg |
Last Reviewed: October 20, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |