+ Reply to Thread
Results 1 to 6 of 6

Protecting and Reading password from text file

Hybrid View

  1. #1
    Registered User
    Join Date
    10-16-2009
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    31

    Protecting and Reading password from text file

    My requirement is that, when the workbook is opened all but Sheet1 should not be visible.
    The other sheet should be visible after inputting the password, which should be read from
    the textfile text2.txt.Currently, this is the last line in the text file, which is "1415167".But actualy, this should be the 15th line after the first date appearance.
    so, in the example file, the 1st date appearance is 04/01/2010, so 15 lines after that would
    be 1st occurance of "Word to find" and then "TEST" is the username and then 1234567 is the password.

    Note : the current as given by the tools--> protection method is 123

    Attaching the excel file as well as the text file.
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Protecting and Reading password from text file

    Please take a few minutes and read the forum rules about cross posting...

    http://www.mrexcel.com/forum/showthread.php?t=497315

  3. #3
    Registered User
    Join Date
    10-16-2009
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Protecting and Reading password from text file

    Quote Originally Posted by jeffreybrown View Post
    Please take a few minutes and read the forum rules about cross posting...

    http://www.mrexcel.com/forum/showthread.php?t=497315
    I have notified in the other forum about this post...
    sorry about this...pl release this so that fellow members can contribute to this issue.

    Thanks,
    Ravin

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Protecting and Reading password from text file

    I do not have your thread here (or there) locked. I am not an administrator/moderator to this board and I really do not know how to read a password from a text file.

    Since Excel is not an entirely secure application anybody with some know-how can crack into your spreadsheet. I see you were initially using a password from a sheet, but then you requested to read a passord from a text file.

    My suggestion would be to hard code your password into the VBA and then password protect your project.

    The code below worked for me.

    Hope this satisfies your needs...if not please let us know

    Private Sub Workbook_Open()
    'ThisWokbook Module
        UserForm1.Show
    End Sub
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    'ThisWokbook Module
        Dim ws As Worksheet
        Application.ScreenUpdating = False
        For Each ws In ActiveWorkbook.Worksheets
            If ws.Name <> "Sheet1" Then
                ws.Visible = False
                ws.Protect Password:="password"
            End If
        Next ws
        Sheets("Sheet1").Protect Password:="password"
        Application.ScreenUpdating = True
    End Sub
    Private Sub CommandButton1_Click()
    'UserForm Code
        Dim ws As Worksheet
        Dim MyPassword As String
        MyPassword = TextBox1.Text
    
        If Sheet1.ProtectContents = True And TextBox1.Text = "password" Then
            For Each ws In ActiveWorkbook.Worksheets
                ws.Visible = True
                ws.Unprotect Password:=MyPassword
            Next ws
        End If
        Call ParseText
        MsgBox ("Called ParseText")
        Unload Me
    End Sub

  5. #5
    Registered User
    Join Date
    10-16-2009
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Protecting and Reading password from text file

    Thanx Jeff, but anybody can crack even the VBA project password too.
    To your point, I am just looking to make the password retrieving harder by using the txt file, which will be on a very very secure server which is accesses by a couple of people in the organization. But if I hardcode the password, then anybody can copy the excel, and crack the password.
    Yes, you are right, intially I have started with the sheet password, but that was because, I was not able get the exact idea of how to go about the use of external password.
    The excel I have attached earlier reads the text file, and gets the password from that file, but how do I use it with the excel sheets?

    Thanks,
    Ravin

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Protecting and Reading password from text file

    Hi Ravin,

    Sorry I probably can't help any further with this matter...just not sure how to incorporate a password from anything outside of Excel.

    In all honestly, I believe you are going to a lot of trouble to protect a password when the reality is, with or without the txt file password somebody can still crack into your spreadsheet if they wanted to.

    Good luck and hope you find what you need. If one of the other professionals here does not come on board but you do find a solution please post back so we can all possibly benefit from the shared knowledge.

+ 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