Checking if a workbook is already open

RunTime91

Active Member
Joined
Aug 30, 2012
Messages
276
Office Version
  1. 365
On to the next problem...

I'm working with several workbooks moving information back and forth and I would like to know how to check if one of the workbooks I'm working with is already open - I've Googled the heck out of this and - nothing I found works.

Below is the closest idea to what I'm looking for - A simple if it is open then do stuff if it is not open then open it and do stuff
but I get a "Sub or Function not defined" error on the IsWorkBookOpen line

Code:
Dim Ret As Boolean
Ret = IsWorkBookOpen("H:\RefAuthAdj\Inventory Control\Inventory\Daily Inventory Current Report\DailyInvReport.xls")
If Ret = False Then
  Workbooks.Open Filename:= _
    "H:\RefAuthAdj\Inventory Control\Inventory\Daily Inventory Current Report\DailyInvReport.xls"
  Else
End If

Thanks for any help on this
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
How about
Code:
Dim Wbk As Workbook
On Error Resume Next
Set Wbk = Workbooks("DailyInvReport.xls")
On Error GoTo 0
If Wbk Is Nothing Then Set Wbk = Workbooks.Open("H:\RefAuthAdj\Inventory Control\Inventory\Daily Inventory Current Report\DailyInvReport.xls")
 
Upvote 0
Works perfectly and allows for multiple uses of this error trap, which is precisely what I needed

Thanks Fluff!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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