View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Testing if a file is open


Dim bk as Excel.Workbook

sPath = "C:\MyFolder\"
vFileName = "MyBook.xls"

On error Resume Next
set bk = Excel.Application.Workbooks(vFileName)
On Error goto 0
if not bk is nothing then
msgbox bk.Name & " is open"
else
set bk = Excel.Application.Workbooks.Open(sPath & vFileName)
end if



--
Regards,
Tom Ogilvy



"jille" wrote in message
...
Hi,

Can someone provide some direction on how to test if an Excel file is
currently open....not worried about whether it is active, just currently
open.

I'm requesting the information from VBA for Word 2000. I've tried the
following:

if Excel.application.workbooks(vFileName).open = true
...
End if

It isn't working!

Any ideas would be very much appreciated.

Thanks,
Jille