PDA

View Full Version : Is File already Open ?



T_Livingston
2004-10-28, 07:27 PM
I am wishing.....Is there a methodProperty that tells me if a file is already Open ?

This is what I have so far which works great...

'Open Microsoft Excel Invoice Log
'----------------------------------------------------------------
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open ("Q:InvoicesAuto-Invoice Log.xls")
objExcel.Sheets("Sheet1").Select
Set objExcelSheet = objExcel.ActiveWorkbook.Sheets("Sheet1")

The only thing I want is the Program to msgbox "File is open" then exit If, infact, the "Auto-Invoice Log.xls is open.

I am trying to "catch" the error here rather than the Err Handler

Thank You
Tim Livingston
Acad 2004VB6

msretenovic
2004-10-28, 09:54 PM
Is this what you are looking for?



set wkBook = objExcel.Workbooks.Open("Q:\Invoices\Auto-Invoice Log.xls")
if wkBook.ReadOnly then
wkBook.close
end if


HTH

T_Livingston
2004-10-29, 01:55 PM
Perfect.

Thank you.

cll
2004-11-05, 07:44 AM
- you can also check this link:

http://www.markrowlinson.co.uk/exceliswbopen.php

Best regards
Claus