+ Reply to Thread
Results 1 to 3 of 3

Macro bug with Sharing and Unsharing

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Macro bug with Sharing and Unsharing

    I wrote two simple macros to share and unshare my workbook. The Unshare one works and the share one does not. Where's my error?

    Here's the unshare one (which works);

    Sub Unshare()
    Dim PWORD As String
    PWORD = "test"
    ActiveWorkbook.UnprotectSharing (PWORD)
    End Sub

    Here's the Share one that does not work;

    Sub share()
    Dim PWORD As String
    PWORD = "test"
    ActiveWorkbook.ProtectSharing sharingpassword:=PWORD
    End Sub

    Thanks for any help.

    ChemistB

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Following should help ...

    Please Login or Register  to view this content.
    HTH
    Carim

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Macros to Protect shared workbook

    After some serious trial and error investigation, here's what I've found;

    If the workbook is unprotected, then the macros work fine. If the workbook is protected, then it crashes when I go to "protect and share." These two functions normally work fine together (outside of macros) and I use them for different reasons.

    I need the workbook protected because that disables the user from unhiding worksheets within it.

    I need the workbook shared and protected because that automatically disables macro editing and also enables the track changes.

    Any suggestions?
    Where I originally thought I was not setting up the macro properly to point to the right workbook, it definitely looks like a Microsoft bug now. Is there an email address to report such bugs? Thanks.

    Original Post:
    I wrote two simple macros to share and unshare my workbook. The Unshare one works and the share one does not. Where's my error?

    Here's the unshare one (which works);

    Sub Unshare()
    Dim PWORD As String
    PWORD = "test"
    ActiveWorkbook.UnprotectSharing (PWORD)
    End Sub

    Here's the Share one that does not work;

    Sub share()
    Dim PWORD As String
    PWORD = "test"
    ActiveWorkbook.ProtectSharing sharingpassword:=PWORD
    End Sub
    Last edited by ChemistB; 12-18-2006 at 03:05 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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