XL7: Run-time Error Using Macro to Access Worksheet in BinderLast reviewed: September 3, 1997Article ID: Q130101 |
The information in this article applies to:
SYMPTOMSIn Microsoft Excel, when you use a Visual Basic, Applications Edition, procedure to create an Office Binder OLE Automation object, and you edit a Microsoft Excel worksheet object in the Binder, you may receive the following error message:
Run-time error '438': Object doesn't support this property or method CAUSEThis behavior occurs when you edit a Microsoft Excel worksheet object in a Binder using OLE Automation if you attempt to access a single sheet (such as a worksheet) or an item on a single sheet (such as a cell value) from outside the Application object without using the Parent object. This behavior occurs because the Microsoft Excel object is a worksheet, even though the section in the Binder is a workbook that you can add sheets to and so on. For example, if you use the following command in a Visual Basic procedure to add a worksheet to section 1 (a Microsoft Excel workbook) in the Binder "MyBinder," you receive the above error message:
MyBinder.Sections(1).Worksheets.AddIf you use the following command to enter the value "test" in cell A1 on the first worksheet in section 1 (a Microsoft Excel workbook) in the Binder "MyBinder," you also receive the above error message:
MyBinder.Sections(1).Worksheets(1).Range("A1").Value = "test" RESOLUTIONTo work around this behavior, use the Parent object to access a Microsoft Excel workbook object, and then use the property or method of the Worksheet object as in the following examples: Microsoft 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." The following command adds a worksheet to section 1 (a Microsoft Excel workbook) in the Binder "MyBinder":
MyBinder.Sections(1).Object.Parent.Worksheets.AddThe following command enters the value "test" in cell A1 on the first worksheet in section 1 (a Microsoft Excel workbook) in the Binder "MyBinder":
MyBinder.Sections(1).Object.Parent.Worksheets(1).Range("A1").Value _ = "test" MORE INFORMATIONFor additional information, please see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID: Q114225 TITLE : XL5: OLE Automation Error Using Quit Method with GetObject REFERENCESFor more information about "Parent Property," click the Index tab in Help and type:
pare |
Additional query words: 7.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |