Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for already opened workbook in excel, using VBA

Status
Not open for further replies.

paulo33

Technical User
Oct 31, 2002
15
0
0
AU
Is there a way for VBA code to check if a particular excel workbook is already open??

Thanks for any help!
 
Sure. You can do something like this:
[blue]
Code:
Option Explicit

Sub test()
Dim oWorkbook As Workbook
  On Error Resume Next
  Set oWorkbook = Workbooks("a.xls")
  If oWorkbook Is Nothing Then
    MsgBox "Workbook a.xls is NOT open"
  Else
    MsgBox "Workbook a.xls IS OPEN"
  End If
  Set oWorkbook = Nothing
End Sub
[/color]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top