+ Reply to Thread
Results 1 to 19 of 19

WHY? Pasword Protect The VBA Editor Error

Hybrid View

  1. #1
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Angry WHY? Pasword Protect The VBA Editor Error

    If you disable the scroll area of a worksheet .... then password protect the VBA Editor so the syntax cannot be viewed ... the scroll area disabling is undone. (Scrolling is allowed)

    #1 - Why does password protecting the VBA Editor undo the scroll lock ?

    #2 - What is the workaround to keep the worksheet scrolling locked after VBA Editor password protection ? (Haven't found anything on the Forum or Net ... yet).

    Thanks.

  2. #2
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: WHY? Pasword Protect The VBA Editor Error

    Are you disabling the scroll area from the Workbook_Open event ?

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: WHY? Pasword Protect The VBA Editor Error

    See the attached.

    Read comments highlighted. Isn't everything on the Internet "true" ? :-)

        '' Rename new sheet to "Format".
        wb2.Sheets("Sheet4 (2)").Name = "Sheet4"
        wb2.Sheets("Sheet4").ScrollArea = "$A$1"        '<-----<<<<< I acquired this syntax from the Internet and it isn't working.
        wb1.Sheets("Sheet4").ScrollArea = "$A$1"        '<-----<<<<< I acquired this syntax from the Internet and it isn't working.
        wb2.Save
        wb2.Close
        Application.ScreenUpdating = True
    Attached Files Attached Files
    Last edited by Logit; 09-18-2016 at 10:23 PM. Reason: Forgot Attachment

  4. #4
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: WHY? Pasword Protect The VBA Editor Error

    This is also on the Internet....

    From http://blog.contextures.com/archives...cel-worksheet/

    NOTE: The Scroll Area has to be set each time the workbook opens.

  5. #5
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: WHY? Pasword Protect The VBA Editor Error

    When I have tried to prevent scrolling on my workbooks,
    I use the entire area that the user is allowed to work with,
    not a single cell as in your example above.

    example
        wb1.Sheets("Sheet4").ScrollArea = "$A$1:$T$45"
    If this has been helpful, please click on the star at the left.

  6. #6
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: WHY? Pasword Protect The VBA Editor Error

    When I need to prevent scrolling on a worksheet,
    I use the entire area that the user is allowed to work with,
    not a single cell as in your example above.

    example
        Sheets("Sheet4").ScrollArea = "$A$1:$T$45"

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: WHY? Pasword Protect The VBA Editor Error

    Thanks !. Its late now here in NC ... I'll give it a try tomorrow.

  8. #8
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: WHY? Pasword Protect The VBA Editor Error

    The issue is the ScrollArea setting not being persistent, it's a "this session only" thing, once the workbook is closed it's gone.

    To have it 'follow' a copied sheet the best you could do is put it in Worksheet_Activate of the sheet being copied and even then it won't work if that particular sheet is the one the workbook opens on.

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: WHY? Pasword Protect The VBA Editor Error

    Couldn't sleep.

    If it only functions "this session only" ... that kinda stinks.

    I have a sheet that can't be scrolled (open / close the workbook as many times as you want, it stays that way) but the VBA Editor is not password protected.

    Hmmm ....

  10. #10
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: WHY? Pasword Protect The VBA Editor Error

    I have a sheet that can't be scrolled (open / close the workbook as many times as you want, it stays that way) but the VBA Editor is not password protected.
    With regards to this particular workbook, taking into account that Private Sub Workbook_Open() in ThisWorkbook module
    and Sub Auto_Open() in a standard module are basically the same thing, (the latter still existing for backwards compatibility)
    in one word, what is the answer to the question of #2 ?

    Have you checked out the link in #4 ?

  11. #11
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: WHY? Pasword Protect The VBA Editor Error

    Have you checked out the link in #4 ?
    Yes. Doesn't work any different than what I've already experienced. Guess it can't be done ?

  12. #12
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: WHY? Pasword Protect The VBA Editor Error

    Is that the answer to the question in #2 or just to checking out the link ?

    Can you post a sample file that you "Guess it can't be done" in ?

  13. #13
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: WHY? Pasword Protect The VBA Editor Error

    Nothing "Cannot be done" it is a hiccup at most -

    Below I am posting a couple code that will loop through all sheets in your file and constrain the scroll area to A1 -

    Private Sub Workbook_Open()
    
        Dim wb As Workbook
        Dim ws As Worksheet
        Dim Pwd As String
        
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .EnableEvents = False
    End With
        
        Set wb = ActiveWorkbook
        
        Pwd = "YOURPASSWORD"
    
        For Each ws In wb.Worksheets
            ws.Unprotect Password:=Pwd
            ws.ScrollArea = "$A$1:$A$1"
            Call Protect_WS(ws, Pwd)
        Next ws
    
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        .EnableEvents = True
    End With
    
    End Sub
    It calls on Protect_WS which is to password protect each sheet individually and apply properties that you desire...
    Be sure to change the True/False to the desired protection

    Sub Protect_WS(ws As Worksheet, Pwd As String)
    
            ws.Protect _
            Password:=Pwd, _
            DrawingObjects:=False, _
            Contents:=True, Scenarios:=False, _
            AllowFormattingCells:=True, _
            AllowFormattingColumns:=True, _
            AllowFormattingRows:=True, _
            AllowInsertingColumns:=True, _
            AllowInsertingRows:=True, _
            AllowInsertingHyperlinks:=True, _
            AllowDeletingColumns:=True, _
            AllowDeletingRows:=True, _
            AllowSorting:=True, _
            AllowFiltering:=True, _
            AllowUsingPivotTables:=True
    End Sub

    IF YOU DONT WANT TO PASSWORD PROTECT INDIVIDUAL SHEETS THEN CHANGE THE CODE TO THIS FOR OPEN_WORKBOOK

    Private Sub Workbook_Open()
    
        Dim wb As Workbook
        Dim ws As Worksheet
        
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .EnableEvents = False
    End With
        
        Set wb = ActiveWorkbook
        
    
        For Each ws In wb.Worksheets
            ws.ScrollArea = "$A$1:$A$1"
        Next ws
    
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        .EnableEvents = True
    End With
    
    End Sub

    Here is a file with the code embedded on a blank sheet.

    TESTME.xlsm
    Password is the file name "TESTME"

    NOTE - By locking down the area to just $A$1 this will prevent the user from being able to navigate around the sheet... is that what you really want? Personally I would lock areas to used ranges... but I do not know the desired outcome so for now... See if this works for what you were attempting...
    Last edited by ELeGault; 09-19-2016 at 02:20 PM.
    -If you think you are done, Start over - ELeGault

  14. #14
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: WHY? Pasword Protect The VBA Editor Error

    ELeGault

    Thank you for your interest and time. Tried running the project .... all I get is a blank Excel window. Looking at the VBA Editor, there is nothing to access for a password. Perhaps its my system.

  15. #15
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: WHY? Pasword Protect The VBA Editor Error

    OK ... got it solved.

    Thank you for your assistance !

  16. #16
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: WHY? Pasword Protect The VBA Editor Error

    Take this opportunity to educate us.... tell us how this was solved.

  17. #17
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: WHY? Pasword Protect The VBA Editor Error

    Humble moment here ....

    Please understand I am not confused or embarrassed for your assistance. For that I am greatly appreciative ! I am confused (and embarrassed to say) that using your suggestion
    in Post #2 worked. It didn't the first attempts but did late today.

    Do others have the same intermittent "issues" with Excel 2007 as I am experiencing ? There seems to be a gremlin living in my computer room.

    Should I upgrade to a later version of Excel ..... or are there similar issues there ?

    I started a few years ago with Visual Basic 6 and did not experience these unusual occurrences.

  18. #18
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: WHY? Pasword Protect The VBA Editor Error

    No problem.

    As for Excel 2007.... too many people on all the different Excel forums use it to think there's any issues to be concerned about. Not sure the issues aren't just "the learning experience".

  19. #19
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: WHY? Pasword Protect The VBA Editor Error

    Thank you for the encouragement. I'll close this out now.

+ 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. Error 400 in Custom UI editor ?
    By RustyNail in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-28-2015, 06:15 PM
  2. Code to password protect VBA Editor
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2015, 05:06 PM
  3. [SOLVED] DLL error when opening VB editor
    By SIMBAtheCAT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2014, 03:51 PM
  4. [SOLVED] Macro to pasword Protect worksheets based on Tab color
    By mturnertombow in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2013, 07:58 AM
  5. Protect Visual Basic Editor with vba = No Go
    By PY_ in forum Excel General
    Replies: 2
    Last Post: 02-15-2011, 08:55 AM
  6. [SOLVED] How doe I protect user defined functions in VB Editor
    By jbowering in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-27-2006, 06:20 PM
  7. How to protect a sheet with pasword
    By filo666 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2005, 03: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