Open Workbook Using VBA

Opening a Workbook Using VBA in Excel

The Excel training video takes you through all the steps involved in writing and executing the macro.

  1. Click on the Tools menu in the menu bar, select Macro and then Visual Basic
  2. In the Visual Basic Editor click on insert in the menu bar and select Module
  3. The first green line with an apostrophe at the beginning denotes a remark and let’s the user know about the utility of the following macro
  4. Define a macro name like OpenUp()
  5. Then complete the code as shown below
  6. Here we use the Open method from the workbooks collection. If you remember last time we used the Add method to create a new workbook.
  7. You’ll notice that you need to define the complete path to the file to be opened
  8. The following procedure in Excel opens a workbook named create-new-work-using-macro.xls located in the sub-folder named My Documents on drive C.

Sub OpenUp()

Workbooks.Open(“C:\Documents and Settings\Dinu\My Documents\create-new-work-using-macro.xls”)

End Sub

We have also shown how to  auto-run the ‘OpenUp’  macro.

Further reading:
Open Method [Excel 2003 VBA Language Reference]

Leave a Reply

Your email address will not be published. Required fields are marked *