Workbooks

This collection allows you to work with a variety of subordinate objects, change properties, and run methods for manipulating workbooks. Further it allows you to add new, open, save, close the workbooks… It also enables the opening of external links, document protection and all other operations to control workbooks in order to improve the experience of working in Excel.

Adding a new workbook is done by using the Add method. See the example:

Sub Nova ()

Dim wb As Workbook
Set wb = Workbooks.Add

End Sub

The Add method can also contain the Template parameter, where we specify the address of the template based on which we want to create a new document. If it is omitted, a new blank document is created.

To open the document, we would use the Open method:

Workbooks.Open (FileName: = “example.xlsx”)

To save a document, we should use the ThisWorkbook property, which indicates an active workbook, as well as the Save method:

ThisWorkbook.Save

To activate workbooks, use the Activate method to close it the Close method.

This object contains many other useful methods and features that you can get familiar with with Object Browser.