Opens a workbook named MyWorkbook.xls located in the same directory as the active workbook. An error is generated if the file cannot be found. : ActiveWorkbook « Excel « VBA / Excel / Access / Word






Opens a workbook named MyWorkbook.xls located in the same directory as the active workbook. An error is generated if the file cannot be found.

 
Sub filePath()
    Dim filePath As String
    filePath = ActiveWorkbook.Path
    Workbooks.Open (filePath & "\" & "MyWorkbook.xls")
End Sub

 








Related examples in the same category

1.Get current active workbook full name
2.Saving Worksheets as Web Pages
3.Previewing a workbook before saving it as a Web page
4.For Each-Next is useful for cycling through each member of a collection
5.Saves the worksheet range "$A$1:$B$11" as a Web page without interactivity so that it can be viewed in any current browser:
6.Looping through a Collection: use the For Each- Next structure
7.Closes the active workbook without saving changes
8.Protects the structure and windows of the active workbook with the password 0llsecurd:
9.Working with the ActiveWorkbook Object
10.Printing a Worksheet
11.Setting Excel to Remove Personal Information from the File Properties When You Save
12.Setting Passwords and Read-Only Recommendation for a Workbook
13.To set a "password to modify," set the WritePassword property of the Workbook object.
14.Opening a New Window on a Workbook
15.Programmatically Retrieving Link Source Information
16.Standard Workbook Properties