+ Reply to Thread
Results 1 to 3 of 3

unshare and unprotect the workbook using one button

Hybrid View

  1. #1
    Registered User
    Join Date
    04-17-2013
    Location
    london
    MS-Off Ver
    Excel 2002
    Posts
    49

    unshare and unprotect the workbook using one button

    I am trying to unshare and unprotect the workbook using one button.
    I'm confused to which loop statement I shoud be using..any ideas?

    see my code below

    Private Sub CommandButton1_Click()
    
    If ActiveWorkbook.MultiUserEditing Then
            Application.DisplayAlerts = False
            ActiveWorkbook.ExclusiveAccess
            Application.DisplayAlerts = True
    
    If Not ActiveWorkbook.MultiUserEditing Then
            Application.DisplayAlerts = False
            ActiveWorkbook.SaveAs ActiveWorkbook.Name, accessmode:=xlShared
            Application.DisplayAlerts = True
            
    ??
    
    ActiveSheet.Unprotect Password:="123", UserInterfaceOnly:=True
    
    End If
    
    End sub
    Last edited by JBeaucaire; 07-29-2013 at 10:12 AM. Reason: Added CODE tags and corrected title, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thank

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: unshare and unprotect the workbook using one button

    May be try this...

    Sub CommandButton1_Click()
    
    Application.DisplayAlerts = False
    
    If ActiveWorkbook.MultiUserEditing Then
        ActiveWorkbook.ExclusiveAccess
    Else
        ActiveSheet.Unprotect Password:="123"
        ActiveWorkbook.SaveAs ActiveWorkbook.Name, accessmode:=xlShared
    End If
    
    Application.DisplayAlerts = True
    
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    04-17-2013
    Location
    london
    MS-Off Ver
    Excel 2002
    Posts
    49

    Re: unshare and unprotect the workbook using one button

    Thanks that works.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Unable to UNSHARE a Workbook
    By PosseJohn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2013, 12:36 PM
  2. Unshare a workbook
    By displaced in forum Excel General
    Replies: 0
    Last Post: 08-26-2009, 10:25 AM
  3. Can't unshare workbook
    By TUSSFC in forum Excel General
    Replies: 1
    Last Post: 05-20-2009, 10:24 AM
  4. how to unshare a workbook?
    By Todd in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 09-06-2005, 07:05 PM
  5. [SOLVED] how to unshare a workbook?
    By Todd in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-07-2005, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1