XL97: Error Message Appears Returning MSGraph Object Name

Last reviewed: March 13, 1998
Article ID: Q172278
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

When you create a macro that references a property of a Microsoft Graph object, the following error message appears:

   Run-time Error '1004':
   Unable to get the Object property of the OLEObject class.

CAUSE

This problem occurs when you do the following:

  • You insert a Microsoft Graph object in a worksheet.

    -and-

  • You attempt to return a property of the Graph object in a macro.

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 engineers 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.

Before you refer to the Microsoft Graph object application, activate the Graph object by using the Activate method of the object. For example, the following macro statement activates a Graph object that is embedded on Sheet1 of a workbook:

   Sheet1.OLEObjects(1).Activate

STATUS

This behavior is by design of Microsoft Graph and Microsoft Visual Basic for Applications.

MORE INFORMATION

You can return the properties of an object in a Visual Basic for Applications macro by referring to the application for the object. For example, the following sample macro returns an embedded Microsoft Graph application name and object name:

   Sub GraphEx()

     Sheet1.OLEObjects(1).Activate
     Set myApp.OLEObjects(1)
     MsgBox "Object name = " & myApp.Name
     MsgBox "Object application name = " & myApp.Object.Application.Name

   End Sub

Note that a run-time error occurs if you attempt to refer to properties for an embedded object unless you open the object. The properties are unavailable to Visual Basic because the object is embedded and the server application is not active.

REFERENCES

For more information about inserting objects in a worksheet, click the Index tab in Help, type the following text

   inserting, embedded object

and then double-click the selected text to go to the "Insert a linked object or embedded object from an existing file" topic.


Additional query words: XL97
Keywords : kbcode kberrmsg kbprg xlchart
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.