Results 1 to 4 of 4
  1. #1
    tdhw
    Guest

    Password protected file (97 SR2)

    Can someone tells me how to write data to a password protected Excel file by VBA?
    I m doing my code to communicate two Excel files, one of them is protected by password. I have completed one way input, i.e. data transfer from the protected file to unprotected file is ok. To write some data to that protected file, I need some method/syntax to stop the program and show a input box to type in the required password. After that the program should resume and be able to write the transferred data to that file/worksheet without stopping until end sub. I guess a couple of lines of code wil do the job but couldnt find a clue from Help files.

    Thanks in advance,

    David

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password protected file (97 SR2)

    Just use the Unprotect method:

    <pre> Worksheets("Sheet1").Unprotect
    </pre>


    If you don't pass it a password parameter, it will prompt for the password.
    Legare Coleman

  3. #3
    tdhw
    Guest

    Re: Password protected file (97 SR2)

    Thanks, Legare. It is so easy. But without your help or this discussion lounge, I might sped hrs to guess/try and still achieve nothing.

    I forgot to ask about how to deal with those who dont have password. I will make a if block to branch users with and without the password. Those without password will click close or cancel on that prompt box and should be able to continue the program by just bypassing this part. Then what expression/property do I need to test in my IFcondition to differentiate the two groups of users?

    David

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password protected file (97 SR2)

    You should not have to do anything different. If it is not password protected, then the method should not prompt for a password.
    Legare Coleman

Posting Permissions

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