Center workbook : Workbook « Excel « VBA / Excel / Access / Word






Center workbook

 
Sub CenterBook()
    Dim bookWidth As Integer
    Dim bookHeight As Integer
    bookWidth = Application.UsableWidth
    bookHeight = Application.UsableHeight
    ActiveWindow.WindowState = xlNormal
    Workbooks("Center.xls").Windows(1).Width = bookWidth
    Workbooks("Center.xls").Windows(1).Height = bookHeight
    Workbooks("Center.xls").Windows(1).Left = 0
    Workbooks("Center.xls").Windows(1).Top = 0
End Sub

 








Related examples in the same category

1.Create a new workbook
2.Creates a new workbook and adds it to the collection, reads the number of workbooks into a variable, and selects all worksheets in the active workbook:
3.Get workbook format
4.To close all open workbooks, use the Close method of the Workbooks collection object.
5.To close a single workbook, use the Close method of the Workbook object. The Close method accepts three optional arguments (SaveChanges, FileName, and RouteWorkbook).
6.To save a workbook from a VBA program, use either the Save methods of the Workbook object.
7.To select the last Workbook object in the collection
8.Activate work book
9.Use a String rather than an index value to reference a workbook
10.Save workbook and close
11.The Workbooks property is a member of the Application object and returns a reference to the Workbook object specified by the index value given in the parentheses.
12.Open workbook by name
13.Close a workbook and save it
14.Create a workbook and save it as a new file
15.The distinction between the Workbook and Window objects lies in an additional method that can be used to create a Window object
16.Open a workbook and then size it to fit just within the application window
17.Use Application object to save a workbook as a new file
18.Add a new workbook and save it
19.arranges the open workbooks in a tiled configuration
20.maximizes any workbook when it is activated
21.places the username in the footer of each sheet printed:
22.Check Whether a Workbook Is Open
23.Check Whether a Sheet in an Open Workbook Exists
24.Count the Number of Workbooks in a Directory
25.Controlling Worksheet Visibility