Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Read / Write Alert - Dave Peterson

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Read / Write Alert - Dave Peterson

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

"GrantW" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Read / Write Alert - Dave Peterson

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)

"GrantW" wrote in message
...
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read/Write Alert GrantW Excel Discussion (Misc queries) 2 June 19th 07 04:35 AM
Dave Peterson Rich_Patterson Excel Discussion (Misc queries) 2 January 26th 07 08:56 PM
Dave Peterson joelbeveridge Excel Discussion (Misc queries) 1 August 4th 06 02:55 AM
Mr Dave peterson, Please help TUNGANA KURMA RAJU Excel Discussion (Misc queries) 5 December 7th 05 05:11 AM
to Dave Peterson Ross Excel Discussion (Misc queries) 2 September 18th 05 04:45 PM


All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"