test for workbook open
Rich,
Here is one way. It opens the book and then closes it if it is read only
Dim sFile As String
sFile = "C:\myTest\Volker1.xls"
On Error GoTo file_error
Workbooks.Open Filename:=sFile
If ActiveWorkbook.ReadOnly = True Then
CreateObject("WScript.Shell").Popup sFile & " is in use/read-only",
5, "Title", vbYesNo
ActiveWorkbook.Close savechanges:=False
Exit Sub
End If
Exit Sub
file_error:
MsgBox "Error " & Err.Number & " on file " & sFile
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Rich C" wrote in message
...
Need a method to see if a file (WORKBOOK) is in use so the
file open command via VBA does not open it read only. It
should display a warning and then a time delay.
Thanks!
|