0

I have several folders with password protected excel files (one excel file per folder). On the 16th of every month I have to enter each password and print the excel files which is a little time consuming. I would like to automate this process with a batch file.

Can someone point me in the right direction?

2
  • 1
    Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?. – DavidPostill Apr 27 '16 at 10:40
  • I have found a question that is approximately what I'm after: superuser.com/questions/332963/… It says that I should use AutoIt but I have no idea how to use it. The script in the above question also doesnt mention password protected excel files. Where do I start if I wanted to make a batch file that prints password protected excel files? – Alex Apr 27 '16 at 11:37
0

From reading the Excel command line switches there are none that allow passing the password via command line.

The best solution is to create a workbook and write a macro that opens your required password protected workbooks (as macros let you do this) and prints them.

You could write the macro to open all the workbooks in a given folder, for example.

If the passwords are the same then you store this in a variable (unsafe) or prompt you for it when you open the blank "stub" worksheet.

Workbooks.Open Filename:="<drive>:\<Folder>\<Workbook>.xls", Password:="<Password>"
3
  • Thank you! So I'll use macro instead of a batch file. The problem is that I don't know much about macros. Do you have any suggestions where I might start to learn how to do this? – Alex Apr 27 '16 at 12:14
  • Do a read up on what you need but my code snippet above should provide the answer to open a file and unlock it with the password defined. You should tailor your code to do what you want... – Kinnectus Apr 27 '16 at 12:20
  • Thanks a bunch! But if I wanted to print the workbook, what snippet would I use then? I tried to google but couldn't find anything useful, or maybe I don't know what to write in the search box. – Alex Apr 28 '16 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.