How can I password protect all word files in a folder?

Anonymous
2012-05-01T22:45:14+00:00

How can I password protect all word files in a folder? I know there is a macro for it I just cant write it. I can't get my head rounf visual basic I am only an admin who has to lock hundreds of files a month with the same password. Please someone give me a magic macro code and how to insert it.

I have been studying forums but I am no cleverer than 3 days ago. Tutorials don't help either.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Jay Freedman 208.1K Reputation points Volunteer Moderator
2012-05-02T14:44:24+00:00

> What am I doing wrong?

You missed this in my post:

>> change the path (be sure to keep the backslash at the end)

So you need to change this line:

     strFilePath = "C:\LOCKIT"

to this:

     strFilePath = "C:\LOCKIT"

The reason nothing was happening is that the Dir$() command takes that string and adds "*.doc*" to the end of it; without the backslash you're getting "C:\LOCKIT*.doc*" as the file to look for, and there is no such file (which would have to be in the root folder, C:).

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

7 additional answers

Sort by: Oldest
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Charles Kenyon 172K Reputation points Volunteer Moderator
    2012-05-02T13:00:16+00:00

    You do not want to open any documents in that directory. Simply open Word on a blank document and run your macro. It does not deal with the open document and that may be preventing the macro from running. Note, I have not analyzed your code.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-05-04T07:12:07+00:00

    Jay!! 

    Thank you!

    You did tell me , yes. I skipped over that detail again and again!

    The macro worked a treat!

    Looking into virtual basics now. Pretty exciting!

    Thanks again for taking the time to look!

    Was this answer helpful?

    0 comments No comments