LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Determine if a shared workbook is open

Is there a way to determine if a shared workbook on a (Novell NetWare)
network drive is in use? I need to be able to replace a locked-down
shared workbook (for viewing by Those Who Should Not Make Changes)
with an updated copy produced from a non-shared Master file. I use a
separate workbook (I have my reasons) to open the Master file, save it
as an intermediate file, lock all its cells, protect all its sheets,
and save the resulting file in place of the old shared workbook.
Trying to save the file when someone has the old shared workbook open
will actually work, but not without some problems. So I don't want
the update code to run if either file is open.

I found the following code on Microsoft's Web site. It properly
determines if the Master workbook is open, but using it to test the
shared file produces a False result (i.e., file is not open) even if
the file is in use.

'-------------------
Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer

On Error Resume Next ' Turn error checking off.
filenum = FreeFile() ' Get a free file number.
' Attempt to open the file and lock it.
Open filename For Input Lock Read As #filenum
Close filenum ' Close the file.
errnum = Err ' Save the error number that occurred.
On Error GoTo 0 ' Turn error checking back on.

' Check to see which error occurred.
Select Case errnum

' No error occurred.
' File is NOT already open by another user.
Case 0
IsFileOpen = False

' Error number for "Permission Denied."
' File is already opened by another user.
Case 70
IsFileOpen = True

' Another error occurred.
Case Else
Error errnum
End Select

End Function
'-------------------

Is there some other method I can use to find out if the shared
workbook is open? I would prefer not to have to actually open it via
code, but I'm willing to do so if there's no better alternative.

Mark Lincoln
 
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
Determine if a workbook is already open [email protected] Excel Programming 6 February 28th 07 04:05 PM
How can I determine who has workbook open? Dean Hinson[_3_] Excel Programming 3 April 20th 05 04:01 PM
error number to determine if shared file is open on "this" machine mark kubicki Excel Programming 1 June 22nd 04 09:48 PM
Determine if a workbook is shared quartz Excel Programming 3 March 2nd 04 10:23 PM
Determine if Workbook is Open or Closed jurgenC![_2_] Excel Programming 2 December 28th 03 10:12 PM


All times are GMT +1. The time now is 06:51 AM.

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

About Us

"It's about Microsoft Excel"