+ Reply to Thread
Results 1 to 7 of 7

Limit Scroll area VBA & Macro Security

  1. #1
    Registered User
    Join Date
    01-27-2014
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    49

    Limit Scroll area VBA & Macro Security

    Hi All and Merry Christmas!

    I have inserted some vb code into my workbook that limits the scroll area on all worksheets with no problems. However, as I intend to distribute this workbook, it was my understanding that the user would see a pop up asking to enable macros when you opened an (.xlsm) file. I emailed this file to myself last night, and when I arrived to work and opened this file, no mention of security popped up. So I continued to see if the vb code I implanted was still working, and it was not. So I went to Macro Security, and saw that it was set to disable all macros. I enabled macros, saved, closed, reopened the file, and then the vb code worked.

    To reiterate, the problem I have with this, is when an unknown user in the agency receives this file, they will not know to enable macros. Is there anyone that has code or any idea on how to disable use of this workbook until the macro security has been enabled? Otherwise, my scroll areas will never be locked. For those that don't know, when you set your scroll area in the VB Editor (properties), this works just fine when the file is still open. However, when you close this file and reopen it, the scroll area you wanted will be gone. This is why I used some vb code to stop this. But now today, I learn that this is still not working because the user (has to know) to enable macros. So I need the workbook to tell the user, sorry charlie, will not work for you until you enable macros first, with a big tongue sticking out. Thanks!

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Limit Scroll area VBA & Macro Security

    Hi colarguns,
    maybe so
    It is assumed that your data is on Sheet1 and Sheet2
    Try to open the file (attached) with the enable macros and disable macros mode.
    Look also code in the ThisWorkbook module
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    01-27-2014
    Location
    Orlando
    MS-Off Ver
    Excel 2016
    Posts
    49

    Re: Limit Scroll area VBA & Macro Security

    Hi Nilem, Thanks for your input. I apologize, but I cannot download for some reason. Must be a glitch on my end. Thanks though!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Limit Scroll area VBA & Macro Security

    @ nilem: You need code in the BeforeSave event. Otherwise, the user could save, then close. The user would be prompted to save changes resulting from hiding the sheets, but if they elect not to, the workbook will next open with all sheets unhidden.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Limit Scroll area VBA & Macro Security

    Hi Shg. Yes, you're right. Then maybe so
    Please Login or Register  to view this content.
    Hi colarguns. Try this link

  6. #6
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Re: Limit Scroll area VBA & Macro Security

    Quote Originally Posted by nilem View Post
    Hi Shg. Yes, you're right. Then maybe so
    Please Login or Register  to view this content.
    Hi colarguns. Try this link
    This code worked great. Can you please explain the below code:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Re: Limit Scroll area VBA & Macro Security

    I am trying to understand the below code and have added in some comments:

    Please Login or Register  to view this content.
    When I click save, I don't want the pages to be hidden, which line of code is making this happen??

    Thanks

+ 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. [SOLVED] VB to remove scroll area limit?
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2014, 01:51 AM
  2. Replies: 3
    Last Post: 08-13-2013, 11:22 AM
  3. Limit scroll area to a union
    By Einstahb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2011, 08:44 PM
  4. Replies: 2
    Last Post: 08-14-2006, 08:15 PM

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