Read / Write Alert - Dave Peterson

G

Guest

Dave, I tried the code concerning IsFileOpen but I get a compile error saying
that Sub or Function is not defined.
The code I'm using is
Sub TestFileOpened()
If IsFileOpen("c:\Book2.xls") Then
MsgBox "File already in use!"
Else
MsgBox "File not in use!"
Workbooks.Open "c:\Book2.xls"
End If
End Sub
I notice that the macro applies up to Excel 97. I'm using 2007 and I find no
help topics in Visual Basic regarding IsFileOpen

Many thanks in advance for suggestions.
 
G

Guest

This should work:-

Sub ordinate()
Dim Book As Workbook
On Error Resume Next
Set Book = Workbooks("book2.xls")
If Book Is Nothing Then
MsgBox "Workbook isn't open", vbCritical
Set Book = Nothing
On Error GoTo 0
Else
MsgBox "Yes it's open", vbInformation
Set Book = Nothing
On Error GoTo 0
End If
End Sub


Mike
 
B

Bob Phillips

IsFileOpen would be a custom function that tests the file. You need to
include that in your project.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top