VBA Excel 2000 - Remove Sharing

Dear Experts,

I would like to remove share by VBA code, so the same which would be done through menu Tools/Share Workbook and removing the flag in section "All changes by more than one user..."

The macro record would do this with a single line

    ActiveWorkbook.ExclusiveAccess

but the problem it brings error message if the file is not shared originally.

Could you please advise how a check could be before this line whether the workbook is shared or not?

thanks,
LVL 1
csehzIT consultantAsked:
Who is Participating?
 
SiddharthRoutConnect With a Mentor Commented:
If you want to do a proper check then use this

If ActiveWorkbook.MultiUserEditing Then
    ActiveWorkbook.ExclusiveAccess
End If

Open in new window


Sid
0
 
SiddharthRoutConnect With a Mentor Commented:
The simplest way to do it is

On Error Resume Next
ActiveWorkbook.ExclusiveAccess
On Error GoTo 0

Sid
0
 
csehzIT consultantAuthor Commented:
Sid thanks very much for both
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.