+ Reply to Thread
Results 1 to 16 of 16

macro that inputs the password on a password protected document

  1. #1
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    macro that inputs the password on a password protected document

    Hi Guys,

    Not too sure if this is even possible.

    I have a number of hyperlinks in a document which when you click on them open up different documents. These are all password protected so when you click on any of the links it will ask you to input the password before the document opens. Would it be possible to create a macro so that when you click on one of these links the password then is automatically populated and opens the document straight away?

    Any help appreciated. Cheers.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: macro that inputs the password on a password protected document

    What sort of documents are they?

  3. #3
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    Hi,

    The document where i have the hyperlinks is an excel document. All the hyperlinks open excel documents.

    Thanks for quick response.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: macro that inputs the password on a password protected document

    I would suggest:
    Change the hyperlink so that it links to it's own cell. Then put some VBA code in to capture the follow hyperlink event and open the workbook in question using the password.

    For example, in A1, if you want to have a hyperlink to E:\test.xls, then for the hyperlink in A1, put the text to display as "E:\test.xls" but put the link to a place in this document with a cell reference of A1.

    Then put this code in the sheet object module of the vba project:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    Think i have misunderstood your instructions. See attached

    it was still prompting me for the password once i clicked on the hyperlink.

    thanks again,
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: macro that inputs the password on a password protected document

    Hi - the code needs to go in the Sheet1 object, not a new module. Take a look at the attached example.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    Oh yes it works. Thanks for all your help this afternoon. Very much apreciated!!!

  8. #8
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    Having thought about it some more, there is potential for more than one hyperlink to be on the sheet therefore meaning hyperlinks to different files with different passwords. How would this code work for multiple hyperlinks?

    THanks very much.

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: macro that inputs the password on a password protected document

    Where would the passwords be stored?

  10. #10
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    The documents which will be hyperlinked are password protected. See attached an example of how one hyperlink would work, im just not sure how i would code for more than one especially if the documents have different passwords.

  11. #11
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    The documents which will be hyperlinked are password protected. See attached an example of how one hyperlink would work, im just not sure how i would code for more than one especially if the documents have different passwords.

    Thanks!!
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    The documents which will be hyperlinked are password protected. See attached an example of how one hyperlink would work, im just not sure how i would code for more than one especially if the documents have different passwords.

    Thanks!!

  13. #13
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: macro that inputs the password on a password protected document

    Hi - the "followhyperlink" event is not specific to one hyperlink. It will run whenever any hyperlink on the sheet is clicked.

    Therefore, if all the hyperlinks have the same password, it should function ok for more than one hyperlink (providing you set all the links up as described previously).

    If the documents have different passwords then the macro needs to find out what the password is for the link that has been clicked - hence the question of where the passwords are stored. How does the code know what password to open the file with? Are they written into the code? are they stored in a look-up table? Are they contained as part of the hyperlink properties (e.g. the texttodisplay is something like "E:\Data.xls :: password"

    Note - perhaps one solution is to remove the passwords from the files?

  14. #14
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    Apologies for the repeated messages. Computer playing up!!

    Unfortunatly the files are in a public folder so need to keep the protection on them.

    So if i stored the passwords in a table on this main document and made the table hidden could this work using the similar method currently being used on the document? Here is another example of my interpretation...
    Attached Files Attached Files

  15. #15
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: macro that inputs the password on a password protected document

    See attached example
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    06-11-2008
    MS-Off Ver
    2003
    Posts
    220

    Re: macro that inputs the password on a password protected document

    Thanks for your example, will i need to copy the code and paste it so it has one for each hyperlink? At the moment it doesnt matter what hyperlink i seem to click it keeps opening the same file???

+ 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. Excel 2007 : Password Protected document
    By usaf_kirby in forum Excel General
    Replies: 2
    Last Post: 09-23-2010, 02:04 PM
  2. modify password protected xls document
    By briana banks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2008, 04:38 AM
  3. [SOLVED] How to see macro code of a password protected macro without a password?
    By Dmitry Kopnichev in forum Excel General
    Replies: 5
    Last Post: 10-27-2005, 05:05 AM
  4. PASSWORD PROTECTED DOCUMENT
    By Tom in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2005, 11:05 AM
  5. Replies: 2
    Last Post: 02-14-2005, 10:06 PM

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