View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Test for Open File

On error resume next
set bk = workbooks("MyBook.xls")
On error goto 0
if not bk is nothing then
msgbox "MyBook.xls is already open in excel"
else
msgbox "MyBook.xls is not open"
End if

if you mean located on a shared drive and being used by someone else:




http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open




--
Regards,
Tom Ogilvy

"Aaron" wrote in message
...
Hi all,

I need to create a If statment that tests if a Xls file is open or not.
Any ideas?

Thanks in advance.
Aaron