Check to see if an existing workbook is open

Wingz

New Member
Joined
Mar 5, 2002
Messages
33
Can anyone tell me the syntax for code that will check to see whether or not an existing workbook is open?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

johny

Board Regular
Joined
Jul 15, 2002
Messages
69
Here is a code I use
I can't remember who I received it from
but it works great compliments from unknown

Dim wBook As Workbook

Application.ScreenUpdating = True
On Error Resume Next
Set wBook = Workbooks("Barschedulle2.xls")
If wBook Is Nothing Then 'Not open
Set wBook = Nothing
On Error GoTo 0
Else 'It is open

MsgBox "You must close down Barschedulle2 first to continue changes", _
vbInformation, "Caution"
Windows("BarScheduLLE2.xls").Activate
Exit Sub
End If
continue your code here then End sub
Thanks Johny
 

Forum statistics

Threads
1,144,743
Messages
5,726,022
Members
422,653
Latest member
mntsiki

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
Top