+ Reply to Thread
Results 1 to 7 of 7

Password Protection and Disapling Macros

Hybrid View

emilyloz Password Protection and... 06-05-2013, 09:10 AM
ragulduy Re: Password Protection and... 06-05-2013, 09:29 AM
AndyLitch Re: Password Protection and... 06-05-2013, 09:32 AM
emilyloz Re: Password Protection and... 06-05-2013, 09:36 AM
emilyloz Re: Password Protection and... 06-05-2013, 09:34 AM
ragulduy Re: Password Protection and... 06-05-2013, 09:39 AM
emilyloz Re: Password Protection and... 06-05-2013, 09:43 AM
  1. #1
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Password Protection and Disapling Macros

    Hello,

    I'm putting a password on my workbook, and I want to disable certain buttons if the workbook is opened in 'Read Only'

    This is what I have so far in the module,
    Private Sub Workbook_Open()
     
        If ThisWorkbook.ReadOnly Then
         
            Sheets("Home Page").Maintenancebtn.Enabled = False
            Sheets("Home Page").Contractorsbtn.Enabled = False
            Sheets("Current Maintenance").UpdateHistory1.Enabled = False
            Sheets("Current Contractors").UpdateHistory2.Enabled = False
     
        End If
    
    End Sub
    This code came from: http://www.mrexcel.com/forum/excel-q...read-only.html

    But nothing is happening, it's still allowing me to click the buttons.

    I have attached a version of my old work book. If you plan on editing and re attaching, please use the password of '1234'

    Many Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Password Protection and Disapling Macros

    That code doesn't look right to me. I'm not sure and this could come from using an old version of excel but I am used to using
    Sheets("Sheetname").shapes("buttonname")
    to reference buttons and I don't think they have an enabled property. Maybe try .visible = false instead?

  3. #3
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Password Protection and Disapling Macros

    Have you tried hitting it with a hammer?
    Elegant Simplicity............. Not Always

  4. #4
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Re: Password Protection and Disapling Macros

    AndyLitch,

    Sarcasm

  5. #5
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Re: Password Protection and Disapling Macros

    yudlugar,
    Nothing has happened.
    Did you mean:
    Sheets("Sheetname").shapes("buttonname").visible = false
    OR
    Sheets("Sheetname").buttonname.visible = false

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Password Protection and Disapling Macros

    Sheets("Home Page").Shapes("Maintenancebtn").visible = False
    Where do you have the code? It needs to be in the "thisworkbook" object in your vba project.

  7. #7
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Re: Password Protection and Disapling Macros

    Oh! that was my problem. I had it in module1.

    It is now working!

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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