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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check whether a Excelworkbook is open

Status
Not open for further replies.

Crookshanks

Technical User
May 18, 2004
296
NL
Hello there,
I've got a simple question. What is the most easiest way in VBA to check whether a certain workbook is open without opening the workbook? Any help appreciated.
Regards,

 
well, easiest way is probably to try to activate it and trap the error if it's not open.

Something along the lines of
Code:
Function WorkbookOpen(WB_Name As String) As Boolean

On Error Resume Next
Application.Windows(WB_Name).Activate

WorkbookOpen = Err.Number = 0

Err.Clear
On Error GoTo 0

End Function

Cheers,

Roel
 
Thanks for your quick answer, but I am afraid that I made a mistake in the question. I want to check whether another user had the workbook open...
 
ah, that's a completely different ballgame...and unfortunately I do not have a ready answer to that.

 

If you try to use the FileCopy statement on a currently open file, an error occurs. So trap that and move on!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top