Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Determine if a workbook is already open | Excel Programming | |||
How can I determine who has workbook open? | Excel Programming | |||
error number to determine if shared file is open on "this" machine | Excel Programming | |||
Determine if a workbook is shared | Excel Programming | |||
Determine if Workbook is Open or Closed | Excel Programming |