COMException with PowerPoint.ApplicationClass (version 11)

S

SimD

Hi,

I have a problem creating a new PowerPoint document from the
Microsoft.Office.Interop.PowerPoint PIA. My application crashes here:
ApplicationClass myApp = new ApplicationClass();
Presentation presentation;
=> presentation = myApp.Presentations.Add
(Microsoft.Office.Core.MsoTriState.msoFalse);

with the following exception:
System.Runtime.InteropServices.COMException
Message: Error HRESULT E_FAIL has been returned from a call to a
COM component.
ErrorCode: -2147467259 (0x80004005)
StackTrace: at Microsoft.Office.Interop.PowerPoint.Presentations.Add
(MsoTriState WithWindow) [ ... ]

I've added references to the Microsoft.Office.Interop.PowerPoint and
the Microsoft.Office.Core assemblies at version 11 (Office 2003). I
only have Office 2003 installed on my machine, with the Office 2007
compatibility pack (Office 2007 isn't installed and has never been
neither). If I add the following line after the creation of the
Application instance:
myApp.Activate();
the main window of PowerPoint shows up as expected and I'm then able
to manually create a new presentation from the GUI (File, New...). I
then execute this line in the immediate window:
presentation = myApp.ActivePresentation;
and I'm then able to execute the rest of my program successfully.

This problem only seems to occur with the PowerPoint interop, since
this code (with the Interop.Word assembly) works well:
object missing = System.Reflection.Missing.Value;
object startIndex = 0;

ApplicationClass myApp = new ApplicationClass();

Document wordDocument = myApp.Documents.Add(ref missing, ref missing,
ref missing, ref missing);

Range documentRange = wordDocument.Range(ref startIndex, ref
missing);
documentRange.Font.Name = "Arial";
documentRange.InsertAfter("Test");

object fileName = @"C:\test.doc";
object fileFormat = WdSaveFormat.wdFormatDocument;
object addToRecentFiles = false;
object saveOptions = WdSaveOptions.wdDoNotSaveChanges;

wordDocument.SaveAs(ref fileName, ref fileFormat, ref missing, ref
missing, ref addToRecentFiles, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing);
myApp.Quit(ref saveOptions, ref missing, ref missing);

I've Googled that error quite a bit in the last few days, and still
didn't find any working solution. I've tried almost everything from
that point on, including uninstalling and reinstalling all Office 2007
system files and updates. I'd really appreciate if anyone could help
me on this, before I start looking for alternatives to create
PowerPoint files...

Thanks !

Simon
 
S

SimD

It seems to be a problem related with the Microsoft Office 2007
compatibility system. I tested it on a workstation without that pack
installed, the version of the PowerPoint interop in the GAC on my side
is 11.0.8161.0, and the version of the one on the other computer is
11.0.5530.0 and that last one is working fine. So it seems to be an
issue with that updated version of the DLL...

It's almost impossible to override the DLL in the GAC without manually
going to %WINDIR%\assembly\GAC\Microsoft.Office.Interop.PowerPoint\,
which I don't think is the appropriate way of doing this. So if
someone knows a workaround or, better, any explanation on what's
really going on behind the scene, I'd like to know...

Thanks !

Hi,

I have a problem creating a new PowerPoint document from the
Microsoft.Office.Interop.PowerPoint PIA. My application crashes here:
        ApplicationClass myApp = new ApplicationClass();
        Presentation presentation;
=>   presentation = myApp.Presentations.Add
(Microsoft.Office.Core.MsoTriState.msoFalse);

with the following exception:
        System.Runtime.InteropServices.COMException
          Message: Error HRESULT E_FAIL has been returned from a call to a
COM component.
          ErrorCode: -2147467259 (0x80004005)
          StackTrace: at Microsoft.Office.Interop.PowerPoint.Presentations.Add
(MsoTriState WithWindow) [ ... ]

I've added references to the Microsoft.Office.Interop.PowerPoint and
the Microsoft.Office.Core assemblies at version 11 (Office 2003). I
only have Office 2003 installed on my machine, with the Office 2007
compatibility pack (Office 2007 isn't installed and has never been
neither). If I add the following line after the creation of the
Application instance:
        myApp.Activate();
the main window of PowerPoint shows up as expected and I'm then able
to manually create a new presentation from the GUI (File, New...). I
then execute this line in the immediate window:
        presentation = myApp.ActivePresentation;
and I'm then able to execute the rest of my program successfully.

This problem only seems to occur with the PowerPoint interop, since
this code (with the Interop.Word assembly) works well:
        object missing = System.Reflection.Missing.Value;
        object startIndex = 0;

        ApplicationClass myApp = new ApplicationClass();

        Document wordDocument = myApp.Documents.Add(ref missing, ref missing,
ref missing, ref missing);

        Range documentRange = wordDocument.Range(ref startIndex, ref
missing);
        documentRange.Font.Name = "Arial";
        documentRange.InsertAfter("Test");

        object fileName = @"C:\test.doc";
        object fileFormat = WdSaveFormat.wdFormatDocument;
        object addToRecentFiles = false;
        object saveOptions = WdSaveOptions.wdDoNotSaveChanges;

        wordDocument.SaveAs(ref fileName, ref fileFormat, ref missing, ref
missing, ref addToRecentFiles, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing);
        myApp.Quit(ref saveOptions, ref missing, ref missing);

I've Googled that error quite a bit in the last few days, and still
didn't find any working solution. I've tried almost everything from
that point on, including uninstalling and reinstalling all Office 2007
system files and updates. I'd really appreciate if anyone could help
me on this, before I start looking for alternatives to create
PowerPoint files...

Thanks !

Simon
 
S

SimD

Self responding again...

VBA hasn't been installed when I installed Office... so that's the
answer to all these problems. Updated the installation, and all
problems are gone now.


It seems to be a problem related with the Microsoft Office 2007
compatibility system. I tested it on a workstation without that pack
installed, the version of the PowerPoint interop in the GAC on my side
is 11.0.8161.0, and the version of the one on the other computer is
11.0.5530.0 and that last one is working fine. So it seems to be an
issue with that updated version of the DLL...

It's almost impossible to override the DLL in the GAC without manually
going to %WINDIR%\assembly\GAC\Microsoft.Office.Interop.PowerPoint\,
which I don't think is the appropriate way of doing this. So if
someone knows a workaround or, better, any explanation on what's
really going on behind the scene, I'd like to know...

Thanks !

I have a problem creating a new PowerPoint document from the
Microsoft.Office.Interop.PowerPoint PIA. My application crashes here:
        ApplicationClass myApp = new ApplicationClass();
        Presentation presentation;
=>   presentation = myApp.Presentations.Add
(Microsoft.Office.Core.MsoTriState.msoFalse);
with the following exception:
        System.Runtime.InteropServices.COMException
          Message: Error HRESULT E_FAIL has been returned from a call to a
COM component.
          ErrorCode: -2147467259 (0x80004005)
          StackTrace: at Microsoft.Office.Interop.PowerPoint.Presentations.Add
(MsoTriState WithWindow) [ ... ]
I've added references to the Microsoft.Office.Interop.PowerPoint and
the Microsoft.Office.Core assemblies at version 11 (Office 2003). I
only have Office 2003 installed on my machine, with the Office 2007
compatibility pack (Office 2007 isn't installed and has never been
neither). If I add the following line after the creation of the
Application instance:
        myApp.Activate();
the main window of PowerPoint shows up as expected and I'm then able
to manually create a new presentation from the GUI (File, New...). I
then execute this line in the immediate window:
        presentation = myApp.ActivePresentation;
and I'm then able to execute the rest of my program successfully.
This problem only seems to occur with the PowerPoint interop, since
this code (with the Interop.Word assembly) works well:
        object missing = System.Reflection.Missing.Value;
        object startIndex = 0;
        ApplicationClass myApp = new ApplicationClass();
        Document wordDocument = myApp.Documents.Add(ref missing, ref missing,
ref missing, ref missing);
        Range documentRange = wordDocument.Range(ref startIndex, ref
missing);
        documentRange.Font.Name = "Arial";
        documentRange.InsertAfter("Test");
        object fileName = @"C:\test.doc";
        object fileFormat = WdSaveFormat.wdFormatDocument;
        object addToRecentFiles = false;
        object saveOptions = WdSaveOptions.wdDoNotSaveChanges;
        wordDocument.SaveAs(ref fileName, ref fileFormat, ref missing, ref
missing, ref addToRecentFiles, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing);
        myApp.Quit(ref saveOptions, ref missing, ref missing);
I've Googled that error quite a bit in the last few days, and still
didn't find any working solution. I've tried almost everything from
that point on, including uninstalling and reinstalling all Office 2007
system files and updates. I'd really appreciate if anyone could help
me on this, before I start looking for alternatives to create
PowerPoint files...
 
I

Idrees Butt

Can you please help me by explaining a bit more how did you resolve this issue as I am getting one for weeks now! Thank You



SimD wrote:

Self responding again...VBA hasn't been installed when I installed Office...
04-Feb-09

Self responding again...

VBA hasn't been installed when I installed Office... so that's the
answer to all these problems. Updated the installation, and all
problems are gone now.


m a call to a
Presentations.Add
ng, ref missing,
ex, ref
;
issing, ref

Previous Posts In This Thread:

COMException with PowerPoint.ApplicationClass (version 11)
Hi,

I have a problem creating a new PowerPoint document from the
Microsoft.Office.Interop.PowerPoint PIA. My application crashes here:
ApplicationClass myApp = new ApplicationClass();
Presentation presentation;
=> presentation = myApp.Presentations.Add
(Microsoft.Office.Core.MsoTriState.msoFalse);

with the following exception:
System.Runtime.InteropServices.COMException
Message: Error HRESULT E_FAIL has been returned from a call to a
COM component.
ErrorCode: -2147467259 (0x80004005)
StackTrace: at Microsoft.Office.Interop.PowerPoint.Presentations.Add
(MsoTriState WithWindow) [ ... ]

I've added references to the Microsoft.Office.Interop.PowerPoint and
the Microsoft.Office.Core assemblies at version 11 (Office 2003). I
only have Office 2003 installed on my machine, with the Office 2007
compatibility pack (Office 2007 isn't installed and has never been
neither). If I add the following line after the creation of the
Application instance:
myApp.Activate();
the main window of PowerPoint shows up as expected and I'm then able
to manually create a new presentation from the GUI (File, New...). I
then execute this line in the immediate window:
presentation = myApp.ActivePresentation;
and I'm then able to execute the rest of my program successfully.

This problem only seems to occur with the PowerPoint interop, since
this code (with the Interop.Word assembly) works well:
object missing = System.Reflection.Missing.Value;
object startIndex = 0;

ApplicationClass myApp = new ApplicationClass();

Document wordDocument = myApp.Documents.Add(ref missing, ref missing,
ref missing, ref missing);

Range documentRange = wordDocument.Range(ref startIndex, ref
missing);
documentRange.Font.Name = "Arial";
documentRange.InsertAfter("Test");

object fileName = @"C:\test.doc";
object fileFormat = WdSaveFormat.wdFormatDocument;
object addToRecentFiles = false;
object saveOptions = WdSaveOptions.wdDoNotSaveChanges;

wordDocument.SaveAs(ref fileName, ref fileFormat, ref missing, ref
missing, ref addToRecentFiles, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing);
myApp.Quit(ref saveOptions, ref missing, ref missing);

I've Googled that error quite a bit in the last few days, and still
didn't find any working solution. I've tried almost everything from
that point on, including uninstalling and reinstalling all Office 2007
system files and updates. I'd really appreciate if anyone could help
me on this, before I start looking for alternatives to create
PowerPoint files...

Thanks !

Simon

It seems to be a problem related with the Microsoft Office 2007compatibility
It seems to be a problem related with the Microsoft Office 2007
compatibility system. I tested it on a workstation without that pack
installed, the version of the PowerPoint interop in the GAC on my side
is 11.0.8161.0, and the version of the one on the other computer is
11.0.5530.0 and that last one is working fine. So it seems to be an
issue with that updated version of the DLL...

It's almost impossible to override the DLL in the GAC without manually
going to %WINDIR%\assembly\GAC\Microsoft.Office.Interop.PowerPoint\,
which I don't think is the appropriate way of doing this. So if
someone knows a workaround or, better, any explanation on what's
really going on behind the scene, I'd like to know...

Thanks !

a call to a
esentations.Add
, ref missing,
, ref
sing, ref

Self responding again...VBA hasn't been installed when I installed Office...
Self responding again...

VBA hasn't been installed when I installed Office... so that's the
answer to all these problems. Updated the installation, and all
problems are gone now.


m a call to a
Presentations.Add
ng, ref missing,
ex, ref
;
issing, ref


Submitted via EggHeadCafe - Software Developer Portal of Choice
Access Web service in client using WSDL file
http://www.eggheadcafe.com/tutorial...f-91215d5b0b81/access-web-service-in-cli.aspx
 

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