+ Reply to Thread
Results 1 to 9 of 9

VBA for password protecting file

  1. #1
    Registered User
    Join Date
    07-11-2010
    Location
    berlin
    MS-Off Ver
    Excel 2003
    Posts
    5

    VBA for password protecting file

    Hy everyone,
    I need help.
    I want to make vba code that will set up password protection for opening word document, also that key for opening should be written on the document, because document is suposed to be printed and then taken to someone who would have to open the same document on some shared server and add some text. only person who get the document physicaly should be able to open the same document on web.
    I have never programmed before in vba, and i would aprecieate any help.
    Thanx

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA for password protecting file

    What do you mean by written on the document?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    07-11-2010
    Location
    berlin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: VBA for password protecting file

    It should go like this.
    After you save the document, or maybe easier when you open it, vba code generates some random number, writes it in first row of document, and that same number is password for opening document later. you print and save the document, put it on some shared folder. you take the printed document to some one who must sign it and maybe add some text in it, so if he wants to open it he must know the random number to open document.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA for password protecting file

    I don't think that work, to get the password or open the document anyone can just not enable macros

  5. #5
    Registered User
    Join Date
    07-11-2010
    Location
    berlin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: VBA for password protecting file

    i know, the word password is weak password. but this is for people who dont understand programming or computers, they just need to write few sentences print document, and after that open the same document using key on printed document. i know that with activedocument.password i can set up password, and range.insertbefore can insert the text

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA for password protecting file

    Not sure if this is what you mean. There's possibly better ways, I don't usually work with Word VBA
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-11-2010
    Location
    berlin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: VBA for password protecting file

    This could be very useful, thanx

    I am having another idea, which could be simplier:

    - in first row of document there is text box, and you type in the password in that text box, and after you save the document, that text becomes document's password

    Is there a simple code for that?

  8. #8
    Registered User
    Join Date
    07-11-2010
    Location
    berlin
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: VBA for password protecting file

    solution with text box is much simplier. I only can't find syntax for taking text out of text box. so in code there should be :
    Please Login or Register  to view this content.
    Last edited by royUK; 07-12-2010 at 10:12 AM.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA for password protecting file

    Try
    Please Login or Register  to view this content.
    And wrap your code with Code Tags in future please

+ 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