XL: Some Window Properties Only Affect Active Worksheet

ID: Q107703

The information in this article applies to:

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 professionals 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/

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 Macintosh Edition, point to
   Macro on the Tools menu, and then click Macros. In the Macro Name list,
   click to 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.

4. 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. Although
   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

Excel 97 and Excel 98 Macintosh Edition

For more information about the Window object, from the Visual Basic Editor, click the Office Assistant, type "window object," click Search, and then click to view "window object."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176476
   TITLE     : OFF: Office Assistant Not Answering Visual Basic Questions

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

Last Reviewed: May 17, 1999