Consulting

Results 1 to 5 of 5

Thread: custom views with a protected worksheet

  1. #1

    custom views with a protected worksheet

    I'd like to use VBA to invoke a Custom View ("CV"), so that the user doesn't need to first unprotect the worksheet and then remember to protect it again after the CV has been invoked. The user would initiate the VBA code by clicking a command button on the worksheet. The code would work something like this:

    1. Collect the names of the CVs already defined for the worksheet.
    2. Display a drop-down list of the names; user chooses the desired CV.
    3. Collect the current protection settings (what's allowed when the worksheet is protected).
    4. Unprotect the worksheet.
    5. Invoke the desired CV using the choice from step.
    6. Protect the worksheet using the protection settings saved in step 3



    Thanks in advance for your consideration,
    Phil

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,057
    Location
    Can you upload a sample workbook please Phil? This will give those members interested in assisting you something to work with, and go a long way to fulfilling your request. To upload an attachment, click on Go Advanced, and scroll down to Manage Attachments.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    Attached is an example that has two custom views. The worksheet is, initially, protected so you cannot switch views without unprotecting the sheet.
    Attached Files Attached Files

  4. #4
    OOPS. The example I posted is NOT PROTECTED, so it does not need to be UNPROTECTED to display custom views. Try this one to demonstrate the behavior I want to deal with:
    Attached Files Attached Files

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Public Sub ShowViews()
        ActiveSheet.Unprotect
        Application.Dialogs(xlDialogCustomViews).Show
        ActiveSheet.Protect
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Tags for this Thread

Posting Permissions

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