+ Reply to Thread
Results 1 to 6 of 6

Fill in password with macro

  1. #1
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Fill in password with macro

    Hi,

    I cant figure out how to fill in a password with VBA when a workbook is openend.
    The idea is when a workbook is openend the macro's should fill in the password to unlock it.

    I want this because when the user does not have macro's turned on they wont gain acces acces to the workbook and thus they need a password to enter. amd so when macro's are turned on. the password will be automaticly filled in and the user wont see the password screen coming up.

    anybody may know how to do this or suggest how to get this ressult?

    grz
    Last edited by vin1; 03-26-2011 at 08:48 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Fill in password with macro

    Hi,

    Why use VBA? Just use Excel's normal password security.
    i.e. in 2003: Tools, Protection, Protect Workbook and enter the relevant password.

    Also note that Excel passwords are not foolproof. There are various macros around that will break them.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Fill in password with macro

    Hi,

    This is the simplest approach I could think of. Begin with your workbook and worksheets locked and put this macro in a standard module

    Please Login or Register  to view this content.
    and this one in ThisWorkbook Object

    Please Login or Register  to view this content.
    It seems to work for me. Tell me if it works for you.

    abousetta
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Re: Fill in password with macro

    I think i did not made the point clear enough.


    When a user turns of macro's i want to be sure they cannot enter the workbook (unless they type in a password or so)

    Because when the macro's are turned off, users may not use the workbook because they may destroy the system.

    So my idea was to put a password on it (Excel normal password not VBA password)
    and if macro's are on an event must be triggered that fills in the password.



    I think its the easyest way is when he asks for the password, an event gets triggered and fills in this password. so when macro's are off the event won't be triggered and the user may not join, unless they know the password.

    So if macro's are on the user wont see the password screen and simply can start doign stuff in the file without breaking anything cause events will protect the file.

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Fill in password with macro

    Good afternoon vin1

    As you know, you cannot force users to enable macros, but you can use VeryHidden sheets, and only make them visible via macros - which therefore have to be enabled. This technoque is discussed here by Ken Puls, along with some sample code.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  6. #6
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Re: Fill in password with macro

    thanks, this should do it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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