running powerpnt.exe with button click

Hi,

Is there a straight forward way to run powerpnt.exe (or any other office program for that matter) via a windows from program.

e.g. Form1 has one button. When the button is clicked, powerpnt.exe (or ideally a *.ppt file) loads.

I was hoping that using system() inside a button click event would work.... It doesn't unfortunately. Or at least I couldn't get it to work.

Cheers,
Last edited on
Thanks chinchu and kbw.

I'll take a look at your suggestions. Since posting my question I also came across this:
http://support2.microsoft.com/kb/222960

My office version and vc++ is more up to date than this but I'm hoping that this will get me a little closer to what I want to do.

I'll return with an update soon....


Cheers.
That's using the automation interface to use PowerPoint at runtime from within your application.

If all you want to do is run it, ShellExecute is what you need. It opens a file and does "something" to it. The verb is a parameter you specify.
Thanks kbw,

I am still trying to get my head around ShellExecute. Thanks for the link and advice... Ideally, this is what I want from what I understand. A button is clicked and the power point file loads no matter where POWERPNT.EXE is located (i think this is the idea behind ShellExecute()). I'm still learning.


I have stumbled upon a site / example but it was in another language (lucky the code is in english).

This works but will not work is one of the computers has a different location for POWERPNT.EXE:

 
using namespace System::Diagnostics;


And for the button click event:

1
2
3
4
5
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 Process^ ps = gcnew Process();
				 ps->StartInfo->FileName = "C:\\Program Files\\Microsoft Office\\Office14\\POWERPNT.EXE";
				 ps->Start("C:\\Test.pptx"); 
			 }


However, I can't seem to get the switch for PowerPoint right. I'm after the 'start as slideshow' which would be the follow at a command prompt:

"C:\Program Files\Microsoft Office\Office14\POWERPNT.EXE" /S "C:\Test.pptx";

Can't get around having too many inverted commas.

Cheers,

Use "open" verb and as file name use only ""test.pptx", ShellExecute will automatically launch associated application (the same behaviour as you double-click the file from explorer)
Like kbw said, if all you need to do is open PowerPoint, then ShellExecute() is real easy. But now you seem to be talking about invoking various methods within the interfaces exposed by PowerPoint. That's going to get complicated real fast, as you'll need to call the automation interface methods. However, its doable.
Topic archived. No new replies allowed.