If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
PowerPoint automation problem
Hi there,
I have a problem concerning PowerPoint automation. To illustrate the problem I wrote a simple test app in c# that looks like this: using System; using Microsoft.Office.Core; using Microsoft.Office.Interop.PowerPoint; namespace PowerPointTest { class Program { static void Main(string[] args) { if (args.Length == 0) return; string presentation = args[0]; ApplicationClass app = new ApplicationClass(); app.Presentations.Open(presentation, MsoTriState.msoCTrue, MsoTriState.msoFalse, MsoTriState.msoFalse); Console.WriteLine("Done!"); } } } This application simply opens a presentation if the path to the file is passed as a parameter. To test the application, I compile it and copy the exe file to the target machine, as well as the interop files (Microsoft.Office.Interop.PowerPoint.dll, office.dll, Microsoft.Vbe.Interop, stdole.dll) and a test ppt file. Starting the app on the target machine actually works and I get the "Done" message on the console, but only if I did a complete installation of Office 2007 on the target machine. If I change the Office 2007 setup to only install PowerPoint and nothing else, the following exception occurs if I start the PowerPointTest application: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --- System.Runtime.InteropServices.COMException (0x80004005): Unbekannter Fehler (Exception from HRESULT: 0x80004005 (E_FAIL)) --- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[]byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) at PowerPointTest.Program.Main(String[] args) The strange thing is that instantiating the ApplicationClass worked, but calling the Open method didn't. The exception text is not very helpful, did not find anything useful on the web. The exception is reproducable with Office XP, Office 2003 and Office 2007 (but only if I install PowerPoint alone and nothing else). I get the same exception if I write the test app using late binding. But I don't think that this is a binding issue, because all needed assemblies (Microsoft.Office.Interop.PowerPoint.dll, office.dll, Microsoft.Vbe.Interop, stdole.dll) are registered in the GAC with the correct version 12. I also tried to install the Office 2007 PIAs on the target machine, but this did not make any change. So I guess it's not an interop problem. So my question is, what else has to be installed on the target machine besides the PowerPoint component? System configuration: Windows XP SP2 running in a VMware (could this be the problem?) ..NET Framework 3.5 SP 1 Thanks for ypur help. Wolfgang |
Thread Tools | |
Display Modes | |
|
|