PowerPoint Automation Error on Close Method for ReadOnly Files

J

Jim Shank

I am trying to do some background processing on PowerPoint 2003 presentation
files using the automation interface through Visual Basic .NET. When the
process accesses write protected (password) files, a prompt is being shown
requesting the password or readonly, I would like to avoid this. I am
specifying readonly in the open method. The other issue is when I close the
file, even when readonly is selected, I get a COMException of "Presentation
(unknown memeber): Invalid Request. Presentation cannot be modified."

Here is the code
Dim m_PowerPointApp As PowerPoint.ApplicationClass
Dim presentation As PowerPoint.Presentation
m_PowerPointApp = New PowerPoint.ApplicationClass
m_powerpointIsOpen = True
m_PowerPointApp.DisplayAlerts =
PowerPoint.PpAlertLevel.ppAlertsNone
presentation =
m_PowerPointApp.Presentations.Open(m_fileName.FullName, ReadOnly:=msoTrue,
WithWindow:=msoFalse)
' Do some reading stuff (nothing is changed)
presentation.Close() ' <-- Here is where the error occurrs

Thanks in advance for any ideas or the solution to this issue. I am running
Office 2003 SP1 on Windows XP SP2. Developing in Visual Studio .NET 2003.
 
S

Steve Rindsberg

Jim Shank said:
I am trying to do some background processing on PowerPoint 2003 presentation
files using the automation interface through Visual Basic .NET. When the
process accesses write protected (password) files, a prompt is being shown
requesting the password or readonly, I would like to avoid this.

So would everyone who'd like to crack password protected files. ;-)
That's why MS makes it difficult.

Try adding

presentation.saved = true

before closing the file.

I am
 

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