I am trying to open a new workbook in VBA. I have pasted the relevant part of my code below. I'm new to VBA so bare with me I have tried various .open formats, but each time I get the same run time error. The file I am trying to open is a Excel 97-2003 file (contains macros). Any help would be greatly appreciated!
Dim FldrPicker As FileDialog
Dim myFolder As String
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
'Response = MsgBox("Please select the folder that contains the Stringer Rating Calculator Files.", 0, "Folder Selection")
If .Show <> -1 Then Exit Sub
myFolder = .SelectedItems(1) & "\"
End With
Filename = Dir(myFolder & "\*.xls")
Do Until Filename = ""
' Append filename to master filename list
Filename = Dir()
If Filename = SubAndMileName & ".xls" Then
myfilename = myFolder & Filename
Set calcbook = Workbooks.Open(myfilename)
GoTo Line1
End If
Loop
Line1:
Dim FldrPicker As FileDialog
Dim myFolder As String
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
'Response = MsgBox("Please select the folder that contains the Stringer Rating Calculator Files.", 0, "Folder Selection")
If .Show <> -1 Then Exit Sub
myFolder = .SelectedItems(1) & "\"
End With
Filename = Dir(myFolder & "\*.xls")
Do Until Filename = ""
' Append filename to master filename list
Filename = Dir()
If Filename = SubAndMileName & ".xls" Then
myfilename = myFolder & Filename
Set calcbook = Workbooks.Open(myfilename)
GoTo Line1
End If
Loop
Line1: