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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

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