XL98: Styles("X").Parent Different in MS Excel 98

Last reviewed: March 16, 1998
Article ID: Q182480
The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

When you run a Visual Basic for Applications macro in Microsoft Excel 98 Macintosh Edition, your macro may behave incorrectly if it accesses the Parent property of a Style object ("Styles.Parent").

CAUSE

This may occur because the Parent property of a Style object is different in Microsoft Excel 98 Macintosh Edition than it is in earlier versions of Microsoft Excel:

   Version(s)                 Parent Property of Style Object Returns
   ------------------------------------------------------------------
   Microsoft Excel 98         a Workbook object
   Microsoft Excel 5.0        the Application object

WORKAROUND

If your macro contains code that accesses the Parent property of a Style object, and you expect the Parent property to return the Application object, you must remove "Parent" from your macro and replace it with "Application". If you do this, the macro will work correctly in Microsoft Excel versions 5.0 and 98.

For example, assume your macro contains the following line of code:

   X = ActiveWorkbook.Styles(1).Parent.Name

You would change this line to:

   X = ActiveWorkbook.Styles(1).Application.Name

STATUS

This behavior is by design of Microsoft Excel 98 Macintosh Edition. The behavior in earlier versions of Microsoft Excel is incorrect.

MORE INFORMATION

In Microsoft Excel, almost every type of object has a Parent property. The Parent property of an object returns the larger object that contains it. For example, ActiveCell.Parent returns the worksheet that contains the active cell.

In earlier versions of Microsoft Excel, the Parent property of a Style object is the Application object ("Microsoft Excel"). This is actually incorrect; the Parent property of a Style object should be the Workbook object that actually contains the style. This change is incorporated in Microsoft Excel 98 Macintosh Edition.


Additional query words: XL98
Keywords : kbprg kbdta xlvbahowto xlvbainfo xl97vbmigrate
Version : MACINTOSH:98
Platform : MACINTOSH
Issue type : kbprb


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 16, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.