XL: Some Window Properties Only Affect Active Worksheet

Last reviewed: February 3, 1998
Article ID: Q107703
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel 97 for Windows
  • Microsoft Excel 98 Macintosh Edition

SUMMARY

In Microsoft Visual Basic for Applications, some Window properties, such as WindowHeadings, affect only the active worksheet in the window.

MORE INFORMATION

Microsoft provides programming examples 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 article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

Window properties, such as scroll bars, gridlines, and worksheet tabs, can be turned on or off using Visual Basic commands. They are accessed as properties of the Window object. Some of these properties affect every worksheet in the window, while others affect only the active worksheet. This behavior is by design, and is consistent with the behavior of the Window Options setting. To set these options, click Options on the Tools menu, and click the View tab.

The following is a list of window properties that affect only the active worksheet in the window.

   DisplayFormulas
   DisplayGridlines
   GridlineColor
   DisplayHeadings
   DisplayOutline
   DisplayZeros

These properties are "per sheet-window" properties. To change these properties on each worksheet in the window, you must select each worksheet before changing the properties.

Steps to Reproduce Behavior

  1. Create a new workbook that contains at least two worksheets.

  2. Insert a new module, and then type the following code:

          Sub Window_Test()
              ' Activate first worksheet.
              ' Substitute name of first worksheet for "Sheet1."
              Sheets("Sheet1").Activate
              ' Turn off vertical scroll bar and row and column headings
              ' in active window.
              With ActiveWindow
                  .DisplayVerticalScrollbar = False
                  .DisplayHeadings = False
              End With
          End Sub
    
    

  3. In Microsoft Excel 97 or Microsoft Excel 98, point to Macro on the Tools menu, and then click Macros. In the Macro Name list, select Window_Test, and click Run.

    In Microsoft Excel 5.0 or 7.0, click Macro on the Tools menu, select Window_Test in the Macro Name/Reference list, and click Run.

       In the first sheet in your workbook, the vertical scroll bar and row and    
    
column headings are turned off.

  1. Select the second worksheet in your workbook.

    The vertical scrollbar is turned off in the second sheet of your workbook, but the row and column headers are still displayed. While both

       are properties of the active window, DisplayHeadings only affects the    
       active worksheet in the window, while DisplayVerticalScrollBar affects 
       all worksheets in the window.
    
    

REFERENCES

For more information about Window Object Properties, click the Search button in Help and type:

   Window Object


Additional query words: 5.00 7.00 8.00 XL98 XL97 XL7 XL5
Keywords : kbcode kbenv kbprg EvnOs
Version : WINDOWS:5.0,7.0,97; MACINTOSH:5.0,98
Platform : MACINTOSH WINDOWS
Issue type : kbinfo


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