Consulting

Results 1 to 4 of 4

Thread: Solved: auto open password protected excel file

  1. #1

    Solved: auto open password protected excel file

    i need to auto-open my password protected excel file in my computer through vba.

    i will save my excel file with default password.

    vba macro should open this my file automatically with default password (which can be included in vba).

  2. #2
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location
    Hi

    You've not given a great deal of info on exactly what you mean but perhaps something like this will give you a start.
    Sub OpenBookTest()
    Dim myFile As String
    Dim myPath As String
    myPath = "C:\My Documents"
    myFile = "My Workbook.xls"
    Workbooks.Open myPath & "\" & myFile, password:="password"
    End Sub
    Is this what you mean?

    Regards
    Iain - XL2010 on Windows 7

  3. #3

    Arrow

    glaswegian, thanku for ur reply,

    I hv solved my solution like this...

    I hv created two toolbar icon namely "Lock file" and "Unlock file"...

    [VBA]

    Sub LockFile()
    '
    ActiveWorkbook.Password = "123"
    ActiveWorkbook.WritePassword = "123"
    End Sub

    Sub UnlockFile()
    '
    ActiveWorkbook.Password = ""
    ActiveWorkbook.WritePassword = ""
    End Sub

    [/VBA]

  4. #4
    Hi
    If you want to open a worksheet
    this is the way :

    Worksheets(i).Unprotect Password:="456"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •