WordCount for password protected PowerPoint presentations

A

Armin Laschet

Hi all,

I'm writing a macro in Word 2003 that should count words in .doc, .xls
and .ppt files. For Word and PowerPoint I use the built-in
ComputeStatistics(wdStatisticWords) and
BuiltInDocumentProperties("Number of words"). I loop over all 5500
files in a folder. That works ok. I managed to let the macro do its job
without any dialogs pooping up, e.g. when a document is
readonlyrecommended or has Auto-Macros etc. For Excel and Word I send a
dummy password, in order to get a run time error, that I catch, so that
I know, that I can't count the words in the respective protected
workbook/document -> (put a respective message in the log file).
Maybe by now you know where I stumble. Since there is no password to be
sent with the open method for a PowerPoint presentation, I cannot go
for a coffee, while my proggy does its job. I have to sit and watch the
screen, if any password dialog comes up that I have to cancel.
I tried the SendKeys procedures supplied by Shyam and, off course, they
don't work for me. It never makes it to the password dialog.

I tried the dsofile.dll as well - gives me word count 0 for each
password protected document.

Has anyone got an idea, how I can find out whether a presentation is
password protected or is there a 'safe' API-kind-of-solution to cancel
the password dialog?

Best regards

Armin Laschet
 
T

The coolest&hottest powerpoint Add-in

Which method do you use for open a PPT file? Is it possbile to detect
if it's password protected before hand? And a bad idea is, would you
like try creating a monitoring tool that keep an eye on that PPT
warning dialog, and dismiss it when it pops up? It will be recommended
to use Microsoft Assessibility interface for such a tool. It should be
quite easy.

Best regards,
KPP
 
A

Armin Laschet

Hi KPP,
Which method do you use for open a PPT file? Is it possbile to detect
if it's password protected before hand? And a bad idea is, would you
like try creating a monitoring tool that keep an eye on that PPT
warning dialog, and dismiss it when it pops up? It will be recommended
to use Microsoft Assessibility interface for such a tool. It should be
quite easy.

Best regards,
KPP

I made a reference in VBE to MS PP 11.0 Object Library and then I try

Sub openPP()
Dim pp As PowerPoint.Presentation, ppApp As PowerPoint.Application
Dim ppPath As String, wrdCnt As Long

ppPath = "C:\MyWork\_WC_\hardcoreTestDocs\PW_PPT.ppt" ' is
password protected
Set ppApp = New PowerPoint.Application
Set pp = ppApp.Presentations.Open(ppPath, msoTrue, msoTrue,
msoFalse)

wrdCnt = pp.BuiltInDocumentProperties("Number of words").Value
pp.Saved = msoTrue
pp.Close
Set pp = Nothing
ppApp.Quit
Set ppApp = Nothing

End Sub

or

Sub openPP2()
Dim pp As PowerPoint.Presentation
Dim ppPath As String

ppPath = "C:\MyWork\_WC_\TestDocs\PW_PPT.ppt" ' is password
protected
Set pp = GetObject(ppPath)

Set pp = Nothing

End Sub

and

Sub openPP3()
Dim pp As PowerPoint.Presentation, ppApp As PowerPoint.Application
Dim ppPath As String

ppPath = "C:\MyWork\_WC_\hardcoreTestDocs\PW_PPT.ppt" ' is
password protected
Set ppApp = New PowerPoint.Application
Set pp = ppApp.Presentations.Open(ppPath, msoTrue, msoTrue,
msoFalse)

Set pp = Nothing
Set ppApp = Nothing

End Sub

Every time the password dialog is displayed, I choose 'Cancel' and get
a runtime error. I don't mind that error. It's that dialog that gives
me pain.
I haven't found a way so far to find out, whether a ppt is protected
before hand. And I guess, there is no way.

About that tool, you suggested: I will go looking for MS Assessibility
stuff, but if that means, the user (I'm not writing the WordCount tool
for my own use) has to start another application, I can already hear
her/him say 'Thanks a lot for your easy to use solution!'.

Thank you for some food for thought anyway.

Best regards

Armin Laschet
 
S

Steve Rindsberg

I tried the dsofile.dll as well - gives me word count 0 for each
password protected document.

Has anyone got an idea, how I can find out whether a presentation is
password protected or is there a 'safe' API-kind-of-solution to cancel
the password dialog?

There's no method for this but I think you may have just supplied your own
workaround.

Not a perfectly accurate, reliable one but it seems reasonable to assume that
MOST of the time, presentations won't have 0 words, so you could save a list of
the ones dsofile reports 0 words for and later manually process those.
Meanwhile, enjoy the coffee.

There might be other properties from dsofile that are even more reliable. If
it tells you that the template is "", for example.
 
A

Armin Laschet

Hi Steve,

Steve said:
There's no method for this but I think you may have just supplied your own
workaround.

Not a perfectly accurate, reliable one but it seems reasonable to assume that
MOST of the time, presentations won't have 0 words, so you could save a list of
the ones dsofile reports 0 words for and later manually process those.
Meanwhile, enjoy the coffee.

There might be other properties from dsofile that are even more reliable. If
it tells you that the template is "", for example.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================

I also considered this a fairly reliable workaround.

In the meantime I talked to my client. He says, that all relevant files
are shared on a network drive among his employees. It's not compliant
with their policy to have password protected documents in that share.
So I just put it as an item into the 'Known Issues' section of my
documentation - the only one, btw ;)

Thank you, guys, for sharing your time and knowledge.

Armin Laschet
 
S

Steve Rindsberg

In the meantime I talked to my client. He says, that all relevant files
are shared on a network drive among his employees. It's not compliant
with their policy to have password protected documents in that share.
So I just put it as an item into the 'Known Issues' section of my
documentation - the only one, btw ;)

Sometimes life just can't get much better. said:
Thank you, guys, for sharing your time and knowledge.

And thank you for mentioning this interesting bit of dsofile behavior.
That might be a workable solution for a lot of people.
 
T

The coolest&hottest powerpoint Add-in

Armin,

I made a test on this and found for password protected PPT file, there
is always a signature like "M.i.c.r.o.s.o.f.t. .B.a.s.e.
..C.r.y.p.t.o.g.r.a.p.h.i.c. .P.r.o.v.i.d.e.r" at the end of the file.
So if you'd like to make a more reliable way to detect if a PPT file is
password protected, you can check the signature in the file. It's an
annoyance, and maybe we need more investigation to find a better
solution. But before that, I hope this work around can help you a
little.

Merry X-Mas!
KPP
----------------------------------------------------------------------------------------------
Do you want a presentation at -459.6 ℉? Try KIBASE Power Pointer
today!

http://www.kibase.com

Armin Laschet 写é“:
 
A

Armin Laschet

Hi guys,

@Steve
And thank you for mentioning this interesting bit of dsofile behavior.
That might be a workable solution for a lot of people.

Great, if I can be of some help for others, since I've found a lot of
very helpful answers in groups in the past.

@KPP
I made a test on this and found for password protected PPT file, there
is always a signature like "M.i.c.r.o.s.o.f.t. .B.a.s.e.
.C.r.y.p.t.o.g.r.a.p.h.i.c. .P.r.o.v.i.d.e.r" at the end of the file.
So if you'd like to make a more reliable way to detect if a PPT file is
password protected, you can check the signature in the file. It's an
annoyance, and maybe we need more investigation to find a better
solution. But before that, I hope this work around can help you a
little.

Hm, that sounds interesting. I'll check that out when I'm home and put
it into my KB.

Merry Xmas to you guys.

Armin Laschet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top