Is file or workbook already open

Steve Jukes

Board Regular
Joined
Apr 15, 2002
Messages
83
I have a workbook that loads a form and from this formn there are optionbuttons set thaif you click them they will open a specific file.
The problem is when you re-click on these optionbuttons the message 'Do you want to re-open file. Re-opening file will.......'. It used to end the code but I have managed to put an 'onerror' command in VBA stopping the breaking of code but it still comes up with this message. Could you please tell me how to stop this message coming up or if there is another way of detecting if the file is already open and therefore only activating the workbook.

Many thanks
Steve
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Or to answer your second question, you can try the following:
Code:
On Error GoTo errorhandler
Windows("Book2.xls").Activate
Exit Sub
errorhandler:
Workbooks.Open "Book2.xls"

Put this code where you have your buttons.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top