I'm trying to write a macro, part of which needs to check if a workbook is already open and if not then open it.
I've grabbed this bit of code from the internet but it's not working as I'd expect as it tries to open the workbook no matter what
Any ideas what might be wrong
On Error Resume Next
Set wb = Workbooks("S:\Gainsborough\Shared Data\Engineering General\DowntimeSheet v2.xlsx")
If Err <> 0 Then 'workbook isn't open
Workbooks.Open Filename:= _
"S:\Gainsborough\Shared Data\Engineering General\DowntimeSheet v2.xlsx", _
UpdateLinks:=0
Windows("Engineer Time.xlsm").Activate
End If
On Error GoTo 0
I've grabbed this bit of code from the internet but it's not working as I'd expect as it tries to open the workbook no matter what
Any ideas what might be wrong
On Error Resume Next
Set wb = Workbooks("S:\Gainsborough\Shared Data\Engineering General\DowntimeSheet v2.xlsx")
If Err <> 0 Then 'workbook isn't open
Workbooks.Open Filename:= _
"S:\Gainsborough\Shared Data\Engineering General\DowntimeSheet v2.xlsx", _
UpdateLinks:=0
Windows("Engineer Time.xlsm").Activate
End If
On Error GoTo 0