I want to open a file by selecting it from a dialog box and set the workbook. Selecting the file and storing the file location in wbCombinedName works fine.
However, wbCombined is not always set properly. E.g. if I have the file open and save it, then run the marco it does not work. When I reopen the file it does work. When I check the variable wbCombined fullname I believe the name of the latest file opened is set.
Is there a way to adjust the below Set statement or should I include a check to see if the to be opened workbook is the already open workbook? Thanks
Set FileO = Application.FileDialog(msoFileDialogFilePicker)
With FileO
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode1
wbCombinedName = .SelectedItems(1)
End With
Set wbCombined = Workbooks.Open(Filename:=wbCombinedName, UpdateLinks:=0)