M
Mischa
Hi,
I tried to write a code that should call a other sub only when a certain
workbook is open.
The names of these workbooks are: map1.xls or; map2.xls or; map3.xls or;
map4.xls or; map5.xls.
If one of the above *.xls file is open, the sub Upgrade should be called.
If no workbook is open then sub PageSelect should be called.
The code is written in mapA.xls
But it does not work ok. You see with my code the sub PageSelect is called
five times if not one of the workbooks is open.
How should a make my code better?
Here is the code :-
---------------------------------------------------
On Error Resume Next
Windows("map1.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
Windows("map2.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
Windows("map3.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
Windows("map4.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
Windows("map5.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
I tried to write a code that should call a other sub only when a certain
workbook is open.
The names of these workbooks are: map1.xls or; map2.xls or; map3.xls or;
map4.xls or; map5.xls.
If one of the above *.xls file is open, the sub Upgrade should be called.
If no workbook is open then sub PageSelect should be called.
The code is written in mapA.xls
But it does not work ok. You see with my code the sub PageSelect is called
five times if not one of the workbooks is open.
How should a make my code better?
Here is the code :-
---------------------------------------------------
On Error Resume Next
Windows("map1.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
Windows("map2.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
Windows("map3.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
Windows("map4.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect
Windows("map5.xls").Activate
If Err = 0 Then Call Upgrade Else Call PageSelect