D
dim
Hi all,
I've run into an unforseen hiccup in my code. I want to test if a workbook
is already open so that I don't try to open it again! In one area I open a
workbook called 3.xls using buttons in my main book called 73.xls.
I want to use a statement, so that if 3.xls is already open, I won't execute
the code Workbooks.Open section. I'm sure its a simple IF THEN ELSE, but with
my effort below I'm getting an "Invalid or Unqualifed Reference" error on the
first line when I try to re-execute the code with 3.xls already open. I
received no error when 3.xls was not open.
I dont have to use an IF statement, one it works I'll be happy....
Thanks
Private Sub CommandButton6_Click()
Application.ScreenUpdating = False
UserForm4.Hide
If Workbooks("3.xls") = .Open Then
Windows("73.xls").Activate
Sheets("CurrentEmployees").Select
Application.ScreenUpdating = True
Else
Workbooks.Open Filename:= _
"C:\Program Files\systems\MyProgram\Data1\3.xls"
Windows("73.xls").Activate
Sheets("CurrentEmployees").Select
Application.ScreenUpdating = True
End If
End Sub
I've run into an unforseen hiccup in my code. I want to test if a workbook
is already open so that I don't try to open it again! In one area I open a
workbook called 3.xls using buttons in my main book called 73.xls.
I want to use a statement, so that if 3.xls is already open, I won't execute
the code Workbooks.Open section. I'm sure its a simple IF THEN ELSE, but with
my effort below I'm getting an "Invalid or Unqualifed Reference" error on the
first line when I try to re-execute the code with 3.xls already open. I
received no error when 3.xls was not open.
I dont have to use an IF statement, one it works I'll be happy....
Thanks
Private Sub CommandButton6_Click()
Application.ScreenUpdating = False
UserForm4.Hide
If Workbooks("3.xls") = .Open Then
Windows("73.xls").Activate
Sheets("CurrentEmployees").Select
Application.ScreenUpdating = True
Else
Workbooks.Open Filename:= _
"C:\Program Files\systems\MyProgram\Data1\3.xls"
Windows("73.xls").Activate
Sheets("CurrentEmployees").Select
Application.ScreenUpdating = True
End If
End Sub