+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    09-29-2005
    Posts
    11

    Change a constant from VB

    Is there a way to change a constant from within VB.

    I know this isn't terribly secure, however it will meet my needs......

    I have a workbook that is protected, with some unprotected fields. The protection password is declared as a constant in the AutoOpen macro ie:

    Password = "1234"

    I then have a lock and unlock button with macros assigned to them to use this password to protect and unprotect the sheet.

    I'd like to give the user the ability to change that password.

    I know I could do this by storing the password string in a hidden sheet in the workbook, but that woudl be very easy for someone to use a different workbook to reference that sheet rom a different file and get the password.

    So what I'd like to do is create a macros that could alter that line of VB .....

    is it possible?

    Clive

  2. #2
    Robin Hammond
    Guest

    Re: Change a constant from VB

    As far as I am aware a constant is just that, and once your code is running,
    any attempt to change it should fail.

    Why not encypt the password in some way and store it in the registry?

    Have a look at SaveSetting in the help files.

    Robin Hammond
    www.enhanceddatasystems.com

    "ccarmock" <ccarmock.27d06n_1146874232.9512@excelforum-nospam.com> wrote in
    message news:ccarmock.27d06n_1146874232.9512@excelforum-nospam.com...
    >
    > Is there a way to change a constant from within VB.
    >
    > I know this isn't terribly secure, however it will meet my needs......
    >
    > I have a workbook that is protected, with some unprotected fields. The
    > protection password is declared as a constant in the AutoOpen macro ie:
    >
    > Password = "1234"
    >
    > I then have a lock and unlock button with macros assigned to them to
    > use this password to protect and unprotect the sheet.
    >
    > I'd like to give the user the ability to change that password.
    >
    > I know I could do this by storing the password string in a hidden sheet
    > in the workbook, but that woudl be very easy for someone to use a
    > different workbook to reference that sheet rom a different file and get
    > the password.
    >
    > So what I'd like to do is create a macros that could alter that line of
    > VB .....
    >
    > is it possible?
    >
    > Clive
    >
    >
    > --
    > ccarmock
    > ------------------------------------------------------------------------
    > ccarmock's Profile:
    > http://www.excelforum.com/member.php...o&userid=27670
    > View this thread: http://www.excelforum.com/showthread...hreadid=539462
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: Change a constant from VB

    If your not going to lock your project, then it would be even easier to look
    in your code to get the password. If you do lock your project, then you
    won't be able to alter it with code. Also, in later versions of excel, the
    user has to allow code to have access to the vbe.

    http://www.cpearson.com/excel/vbe.htm

    --
    Regards,
    Tom Ogilvy

    "ccarmock" <ccarmock.27d06n_1146874232.9512@excelforum-nospam.com> wrote in
    message news:ccarmock.27d06n_1146874232.9512@excelforum-nospam.com...
    >
    > Is there a way to change a constant from within VB.
    >
    > I know this isn't terribly secure, however it will meet my needs......
    >
    > I have a workbook that is protected, with some unprotected fields. The
    > protection password is declared as a constant in the AutoOpen macro ie:
    >
    > Password = "1234"
    >
    > I then have a lock and unlock button with macros assigned to them to
    > use this password to protect and unprotect the sheet.
    >
    > I'd like to give the user the ability to change that password.
    >
    > I know I could do this by storing the password string in a hidden sheet
    > in the workbook, but that woudl be very easy for someone to use a
    > different workbook to reference that sheet rom a different file and get
    > the password.
    >
    > So what I'd like to do is create a macros that could alter that line of
    > VB .....
    >
    > is it possible?
    >
    > Clive
    >
    >
    > --
    > ccarmock
    > ------------------------------------------------------------------------
    > ccarmock's Profile:

    http://www.excelforum.com/member.php...o&userid=27670
    > View this thread: http://www.excelforum.com/showthread...hreadid=539462
    >




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.2.0