Cinema
12-06-2015, 08:16 AM
Hello,
I want to open a workbook with path which is stated in the Range B1 of the Active Workbook. My code gives me the Runtime error 1004 and says that the Workbook cannot be found although the name is correct.
Here is my code:
Sub OpenReport()
Dim path As String
path = ActiveWorkbook.Worksheets("Sheet1").Range("B1").Value
Dim name As String
name = ActiveWorkbook.Worksheets("Sheet1").Range("B2").Value
Workbooks.Open Filename := path & name
End Sub
in B1 there is the path : C:\Users\BenutzerXY\Desktop\
in B2: Map1.xls
I want to open a workbook with path which is stated in the Range B1 of the Active Workbook. My code gives me the Runtime error 1004 and says that the Workbook cannot be found although the name is correct.
Here is my code:
Sub OpenReport()
Dim path As String
path = ActiveWorkbook.Worksheets("Sheet1").Range("B1").Value
Dim name As String
name = ActiveWorkbook.Worksheets("Sheet1").Range("B2").Value
Workbooks.Open Filename := path & name
End Sub
in B1 there is the path : C:\Users\BenutzerXY\Desktop\
in B2: Map1.xls