+ Reply to Thread
Results 1 to 7 of 7

password lost when reopening workbook

Hybrid View

  1. #1
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    password lost when reopening workbook

    Basically i have password to protect selected sheets.
    Then ask for password to protect entire sheet.
    The problem is that the inputted password is lost when closed and reopen the workbook.
    And i can't find the bug in this one. I think another eye would be very helpful. Thanks.


    Option Explicit
    Public pWord1 As String
    Public pWord2 As String
    
    Private Sub CommandButton3_Click()
    Const PW As String = "scorpion" 
    ActiveSheet.Unprotect PW
    pWord1 = InputBox("PLEASE TYPE PASSWORD TO PROTECT. SALAMAT")
    ActiveSheet.Cells.Locked = True
    Columns("AA").Hidden = True
    Columns("AE").Hidden = True
    ActiveSheet.Protect Password:=pWord1
    CommandButton3.Enabled = False
    CommandButton4.Enabled = True
    End Sub
    
    Private Sub CommandButton4_Click()
    Const PW As String = "scorpion" 'hehehe secret ko ito
    pWord2 = InputBox("PLEASE TYPE PASSWORD TO UN_PROTECT. ")
    If pWord2 = pWord1 Then
    ActiveSheet.Unprotect pWord1
    ActiveSheet.Cells.Locked = False
    Columns("AA").Hidden = False
    Columns("AE").Hidden = False
    ActiveSheet.Protect PW
    CommandButton4.Enabled = False
    CommandButton3.Enabled = True
    Else
    MsgBox "YOU HAVE TYPE A WRONG PASSWORD", vbInformation
    End If
    End Sub
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  2. #2
    Forum Contributor
    Join Date
    08-11-2012
    Location
    bengalur
    MS-Off Ver
    Excel 2003, 2007
    Posts
    152

    Re: password lost when reopening workbook

    Please try this code


    Moderator's Note: Sorry i have to delete that code, against forum rules.
    Last edited by vlady; 08-24-2013 at 02:32 AM.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: password lost when reopening workbook

    Hi, vlady,

    you would need to store the password (in the CustomProperties of the workbook, a name, a range in a hidden sheet, a text file, the registry) in order to rely on these. You may even put that password into the code but I prefer not to do so but keep it away. Also check the length of the password and assign a value to it if it is still 0.

    In your second code you protect with a given password. Please make sure to assign that password to your variables as well.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: password lost when reopening workbook

    sorry it's against rule to post bypassing passwords. and my issue is the code aboce on what am i missing.just cann't find it.

    the issue is pWord1 losses it's containment( the password typed) when save/closed then reopen the workbook but still it is password protected.
    Last edited by vlady; 08-24-2013 at 02:36 AM.

  5. #5
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: password lost when reopening workbook

    yup but the problem is there would be a change of password now and then for pword1.


    ...You mean paste the value of pword1 in a cell when protecting then turn that cell blank after unprotect.. i think i got the idea if that's what you mean.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: password lost when reopening workbook

    Hi, vlady,

    thatīs why I mostly use a UserForm with 2 TextBoxes (which show * as password character instead of the clear characters typed in) and 2 CommandButtons (Cancel and OK). The logic of doing all is behind OK: check the passwords against each other to be identical, compare them to the values at the given place, adjust password if needed, make sure to save the changes to the workbook. And maybe even use encryption for storing and reading the password (up to you and the effort you would like to take for keeping it away from the eyes of the user).

    Ciao,
    Holger

  7. #7
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: password lost when reopening workbook

    Thanks. I've edited it now. i did not use userform since i think this will slow down since there will be too many sheet tabs and each sheet tabs will have two buttons for protecting and unprotecting. i used a cell that will be hidden also when the user protects if way down to last row.. thanks to the idea.

    Solves the problem.

    Regards,
    Vladimir

+ 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. How to unprotect a workbook if the password is lost
    By CantripGhost in forum Excel General
    Replies: 2
    Last Post: 12-21-2010, 09:50 AM
  2. Workbook password lost
    By hasin in forum Excel General
    Replies: 1
    Last Post: 01-10-2010, 01:53 AM
  3. Accessing password proteced files when you have lost the password.
    By ekaten in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-17-2008, 12:36 AM
  4. [SOLVED] How do i recover my lost password of workbook?
    By Saiful Islam Rana in forum Excel General
    Replies: 1
    Last Post: 11-20-2005, 05:41 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