Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hello All,
I am working on a project that requires a user to push a macro button that will open a file specified in a drop down list. The file may be .XLS or a .XLSM and there would be no way for the user to know this so I need the code to look and see if it is a XLS and IF Not then Open the XLSM version of the file.
Here is my code but it is not working? Any ideas would help even if the way I am doing this can be simplified with different code.
I am working on a project that requires a user to push a macro button that will open a file specified in a drop down list. The file may be .XLS or a .XLSM and there would be no way for the user to know this so I need the code to look and see if it is a XLS and IF Not then Open the XLSM version of the file.
Here is my code but it is not working? Any ideas would help even if the way I am doing this can be simplified with different code.
Code:
varCellvalue = Sheets("Main").Range("B24").Value
varcell = Sheets("Main").Range("B20").Value
Dim Destbook As Workbook
On Error Resume Next
Set Destbook = Workbooks(varCellvalue & ".xlsm")
On Error GoTo 0
If Destbook Is Nothing Then
Set Destbook = Workbooks.Open("\\Lax-Netapp01\Dept_private\Business Systems\LFC MACRO TEST\" & varCellvalue & ".xlsm")
On Error GoTo 0
If Destbook Is Nothing Then
Set Destbook = Workbooks.Open("\\Lax-Netapp01\Dept_private\Business Systems\LFC MACRO TEST\" & varCellvalue & ".xls")
Else
Destbook.Activate
End If
Sheets("ODM").Select
Range("H11").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True