Macros to show user name when opening locekd Excel file

TK2

New Member
Joined
Dec 17, 2009
Messages
3
Hi.

My Excel file is located on network drive and I have a macros which automatically exports data from outlook message to excel file.

In case some other user has opened this file I can not run a macros, because file is read only.

excel_multiple.jpg


There is a KB article "Macro code to check whether a file is already open".
http://support.microsoft.com/kb/291295

My question is:
"How to show username of person who have locked the file?"

E.g.

If IsFileOpen("c:\Book2.xls") Then
' Display a message stating the file in use.
MsgBox "File already in use by: " + username
'
' Add code here to handle case where file is open by another
' user.
'
End if
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi TK2

If you dont want at another people can open it, give the file password.

If You want at they can open it, share the file. Tools, shareworkbook.

Then you can use it normaly. And you can see later how have change it

-Joxu
 
Upvote 0
Hi

See if this helps.
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0
Not tested but perhaps another way (From Help). Paste below in the Thisworkbook Code Sheet

Code:
Private Sub Workbook_Open()
With ActiveWorkbook
    If .WriteReserved = True Then
        MsgBox "This file is not Shareable - Please contact " & .WriteReservedBy & Chr(13) & _
            " if you need to insert data in this workbook."
    Me.Close SaveChanges:=False
    End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top