Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default I want "locked for editing" message

I like the message that says

Wbook.xls is locked for editing
by 'Username'
Click 'Notify' to open a read-only copy of the document and
receive notification when the document is no longer in use.

But if I open a workbook via

Workbooks.Open Filename:="Wbook.xls"

...it just opens Read-only, which is not what I want.

Can I get VBA to do this, so the user would be notified? I could
duplicate the text in VBA, but it wouldn't notify anybody.

Dan Williams
danwPlanet

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default I want "locked for editing" message

Dan,

1. Test to see if workbook is already open, if yes, let users know via
msgbox...
Private Function IsFileOpen(FileName As String)
Dim iFileNum As Integer
Dim sErrDescr As String
Dim iErrNum As Integer
On Error Resume Next
iFileNum = FreeFile()
Open FileName For Input Lock Read As #iFileNum
Close iFileNum
iErrNum = Err
sErrDescr = Err.Description
Select Case iErrNum
Case 0
IsFileOpen = False
Case 70 'Permission Denied
IsFileOpen = True
Case 53
IsFileOpen = False
Case Else
IsFileOpen = "Error #: " & iErrNum & " - " & sErrDescr
End Select
End Function



2. When you open a workbook, you have several optional parameters:
Workbook.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable,
Notify, Converter, AddToMru, Local, CorruptLoad).

So your code would read something like:
Workbooks.Open Filename:="Wbook.xls", Notify:=True

Good Luck!!
--
Thx
MSweetG222



"Dan Williams" wrote:

I like the message that says

Wbook.xls is locked for editing
by 'Username'
Click 'Notify' to open a read-only copy of the document and
receive notification when the document is no longer in use.

But if I open a workbook via

Workbooks.Open Filename:="Wbook.xls"

...it just opens Read-only, which is not what I want.

Can I get VBA to do this, so the user would be notified? I could
duplicate the text in VBA, but it wouldn't notify anybody.

Dan Williams
danwPlanet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default I want "locked for editing" message

Thanks!

(I had deleted my posting when I realized I should have gone back to
Help and looked at Workbooks.Open. Then I saw your reply, which in
Google Groups now appears as a reply by itself. I replied with a
thank-you, but now when I look in Google Groups, my thank-you didn't
take, so here's another try. Thanks again!)
Dan

MSweetG222 wrote:
Dan,

1. Test to see if workbook is already open, if yes, let users know via
msgbox...
Private Function IsFileOpen(FileName As String)
Dim iFileNum As Integer
Dim sErrDescr As String
Dim iErrNum As Integer
On Error Resume Next
iFileNum = FreeFile()
Open FileName For Input Lock Read As #iFileNum
Close iFileNum
iErrNum = Err
sErrDescr = Err.Description
Select Case iErrNum
Case 0
IsFileOpen = False
Case 70 'Permission Denied
IsFileOpen = True
Case 53
IsFileOpen = False
Case Else
IsFileOpen = "Error #: " & iErrNum & " - " & sErrDescr
End Select
End Function



2. When you open a workbook, you have several optional parameters:
Workbook.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable,
Notify, Converter, AddToMru, Local, CorruptLoad).

So your code would read something like:
Workbooks.Open Filename:="Wbook.xls", Notify:=True

Good Luck!!
--
Thx
MSweetG222



"Dan Williams" wrote:

I like the message that says

Wbook.xls is locked for editing
by 'Username'
Click 'Notify' to open a read-only copy of the document and
receive notification when the document is no longer in use.

But if I open a workbook via

Workbooks.Open Filename:="Wbook.xls"

...it just opens Read-only, which is not what I want.

Can I get VBA to do this, so the user would be notified? I could
duplicate the text in VBA, but it wouldn't notify anybody.

Dan Williams
danwPlanet



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default I want "locked for editing" message

No problem. Thx for the reply.
--
Thx
MSweetG222


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
"Locked for Editing" error on a non-protected file Jim Murray Excel Discussion (Misc queries) 1 March 8th 08 11:42 AM
"Locked for Editing" problem in Excel 2007 Adam Excel Discussion (Misc queries) 1 August 22nd 07 03:29 AM
Getting message: ".xls is locked for editing by ------" Alleysdad101 Excel Discussion (Misc queries) 2 February 7th 07 07:40 PM
Prevent "XYZ.doc is locked for editing" message Greg Wilson Excel Programming 2 September 5th 05 09:17 AM
Not getting "Locked for Editing" message grinnineddies Excel Discussion (Misc queries) 0 June 17th 05 04:29 PM


All times are GMT +1. The time now is 03:15 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"