Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default checking to see if a "shared" workbook is already open

I want to check if a SHARED workbook is open (on the user's machine), so
that I can run code to open it if it is not (otherwise I would get a message
about opening an already open ... ) the workbook is HIDDEN to the user, so the
message would be both inappropriate and confusing...

in the past I've used this procedure, and it worked fine, but the workbook was NOT SHARED
currently i'm getting a errornum 0 (indicating the file is not open) even though it is open (on the user's machine):

Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer
On Error Resume Next
filenum = FreeFile()
Open filename For Input Lock Read As #filenum
Close filenum
errnum = Err
On Error GoTo 0
Select Case errnum
Case 0
IsFileOpen = False
Case 70
IsFileOpen = True
Case Else
Error errnum
End Select
End Function

it was suggested that I check for the workbooks status, but that doesn't
tell me if it is "open" on the user's machine (only if is shared or
exclusive...)

Dim vMode
On Error Resume Next
If Me.ReadOnly Then
vMode = 3
Else
vMode = Application.VLookup(Application.UserName, Me.UserStatus, 3)
End If
MsgBox "Mode: " & Choose(vMode, "exclusive", "shared", "readonly")

thanks in advance,
mark


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
How to Activate "Show all" in a Protected Shared Workbook Anahid Excel Discussion (Misc queries) 1 November 27th 09 01:44 PM
Shared Workbook is "locked for editing" susu Excel Worksheet Functions 0 April 17th 08 04:38 PM
"Shared Workbook" seems to deactivate features like macros Steve Excel Discussion (Misc queries) 3 May 1st 07 05:11 PM
Shortcut key for "Paste Options" and "Error Checking" buttons? johndog Excel Discussion (Misc queries) 1 October 6th 06 11:56 AM
error number to determine if shared file is open on "this" machine mark kubicki Excel Programming 1 June 22nd 04 09:48 PM


All times are GMT +1. The time now is 11:57 PM.

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"