Thursday, December 16, 2004

Getting data from PowerPoint

Another programming challenge, how to get the text from a PowerPoint file. Well, I am currently using Office automation to get the data, this isn't a permanent solution but will do for now. I am only having trouble with password protected (Read-only mode) files. This is better outlined in a newsgroup thread at MSDN.

Here is my request:

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

[code lang='vb']
Dim m_PowerPointApp As PowerPoint.ApplicationClass
Dim presentation As PowerPoint.Presentation
m_PowerPointApp = New PowerPoint.ApplicationClass
m_powerpointIsOpen = True
m_PowerPointApp.DisplayAlerts =
presentation =
m_PowerPointApp.Presentations.Open(m_fileName.FullName, ReadOnly:=msoTrue,
' 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.

No comments:

Post a Comment