Question

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.

Was it helpful?

Solution

It 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

OTHER TIPS

Consider looking at this - http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx

For a PPTX document, you can examine the first 8 bytes to look at the header (should be [d0cf 11e0 a1b1 1ae1] for an encrypted file), and know if it is an encrypted PPTX or not.

However, for files created with Office 2003 (default extension .ppt), the header is the same (MS-CFB header). So, if somebody creates an office 2003 document and then renames it to a PPTX, your code will consider it as an encrypted document (whereas, it wouldn't necessarily be one).

If you are working with documents already opened in Powerpoint, you can use the SaveCopyAs function to first save the document to disk in the pptx format (use the default option in the second parameter), and then examine the header to check if it's an encrypted file.

Consider looking at this - https://msdn.microsoft.com/ko-kr/library/dd948895(v=office.12).aspx

For a PPT(office 2003) document, you can examine the unsigned integer(0xF3D1C4DF bits) to identify whether the file is encrypted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top