VB and VBA Users Source Code: Changing an Excel Worbook's shared status
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Changing an Excel Worbook's shared status
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Sunday, February 02, 2003
Hits:
1627
Category:
Office
Article:
The code below shows you how to change the shared status of an open Excel Workbook. 'Purpose : Changes the Shared status of a workbook 'Inputs : oWkb The workbook to set the shared status of ' bShare If True, sets the workbook to be shared, ' else makes the workbook exclusive. ' [lUpdateFrequency] If specified is the number of minutes between automatic updates. ' Otherwise updates will only occur when the workbook is saved. 'Outputs : Returns True on success 'Author : Andrew Baker 'Date : 13/11/2002 10:14 'Revisions : Function WorkbookSetShare(oWkb As Workbook, bShare As Boolean, Optional lUpdateFrequency As Long = 0) As Boolean On Error GoTo ErrFailed Application.DisplayAlerts = False If bShare Then If oWkb.MultiUserEditing = False Then 'Save the workbook as a shared workbook oWkb.SaveAs ActiveWorkbook.FullName, , , , , , xlShared If lUpdateFrequency Then oWkb.AutoUpdateFrequency = lUpdateFrequency End If End If Else If oWkb.MultiUserEditing = True Then 'Set the workbook to be exclusive '(note, all other users will NOT be able to save their changes) oWkb.ExclusiveAccess End If End If Application.DisplayAlerts = True 'Success WorkbookSetShare = True Exit Function ErrFailed: 'Failed Debug.Print "Error in WorkbookSetShare: " & Err.Description WorkbookSetShare = False End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder