Window Object

Microsoft Office Web Components Visual Basic

Window Object

Multiple objects Window
Multiple objects

Represents a window. Many worksheet characteristics, such as scroll bars and gridlines, are actually properties of the window. The Window object is a member of the Windows collection. Each worksheet has a unique Window object. Code can only access the window for the active sheet of the workbook. In other words, although the Windows collection states that there is only one Window object, there are, in fact, multiple Window objects, but you may only access the Window object for the active sheet.

Using the Window object

The following properties return a Window object.

The Spreadsheet object's ActiveWindow property.

The Windows collection's Item property.

The following example hides the row and column headings in the active window of Spreadsheet1.

Sub HideHeadings()

   Spreadsheet1.ActiveWindow.DisplayColumnHeadings = False
   Spreadsheet1.ActiveWindow.DisplayRowHeadings = False

End Sub
		

The following example moves column C so that it's the leftmost column in the window.

Spreadsheet1.ActiveWindow.ScrollColumn = 3