+ Reply to Thread
Results 1 to 2 of 2

Calling a private procedure from ThisWorkbook

  1. #1
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Calling a private procedure from ThisWorkbook

    I lock all of my worksheets to prevent modification of data and to control user workflow (also to do a meager attempt at protecting work product).

    In the past I've been putting ActiveSheet.Unprotect Password="xxx" along with a Protect statement and a few other lines of code at the end on every page to allow certain VBA routines to make necessary modifications on the worksheet. I recently thought that if I were to add this code to a set of procedures in ThisWorkbook and call it I could stop having to add the same code over and over to my worksheet VBA code. The trouble is that in doing so, I need to make the procedures Public, which sorta defeats the purpose if anyone can run the code from the Macro window.

    So either I need to find a way to hide the code or maybe I'm going about unlocking and locking the wrong way entirely?

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Calling a private procedure from ThisWorkbook

    Hi,

    If you pass the password as an argument to the routine, then the routine won't appear in the macros dialog box. Or, if you prefer, you can simply add Option Private Module to the top of the module containing the protection code.
    Last edited by xlnitwit; 06-28-2016 at 04:12 AM.

+ 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. Calling Procedure or Function inside another Procedure - variables problem
    By Rudo123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2015, 03:12 PM
  2. [SOLVED] Problem with ThisWorkbook Module: Two Private Sub Workbook_Open()
    By DavidRoger in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2015, 11:28 AM
  3. [SOLVED] How to stop Private sub Sheet change (located at Thisworkbook) working in worksheet 3
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2013, 09:34 PM
  4. Replies: 0
    Last Post: 10-02-2012, 03:06 PM
  5. Can't run Private procedure from Autoshape
    By jagman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2008, 06:33 PM
  6. Calling a private sub
    By goofy78270 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2007, 02:47 PM
  7. [SOLVED] private sub- which procedure called it
    By Sunil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2005, 08:05 AM

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