I'm writing an application that processes PowerPoint presentations and I'm looking into ways of detecting whether or not a PowerPoint presentation has a password if it does then stop processing it. Any thoughts?
views:
229answers:
1It seems to me that there is no way to check if the presentation is password-protected. You have to open the document first to make properties accessible. You have to provide the password when you are opening the document.
There is a Password Property you can check.
I've found a workaround on Expert Exchange:
The problem is the following: Visual Basic is a single threaded application, this means that you cant put a certain procedure on hold and proceed with another (in the same application). When powerpoint has an "on open"-password set, the CreateObject procedure inside your application is put on hold untill powerpoint releases it, this is when the user types in a password. There is no way around this that I know off, but you can make a workaround:
Make 2 applications, 1 application is the application you already have, the second one is a "powerpoint unlocker". You run the second program just before you open the protected powerpoint presentation in application 1. You can do that with the shell command. The "powerpoint unlocker" can be as advanced as you want it to be, you can for example provide command line parameters to specify which presentation must be unlocked with what password. Then you use the findwindow api to get the window handle of the locked presentation. Once you have that, you use the sendmessage api to input the password. After this the "powerpoint unlocker" unloads and the first application can resume with its excution.
I hope this helps!
Osmodean