By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,671 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,671 IT Pros & Developers. It's quick & easy.

programmatically creating powerpoint macro

P: n/a
Everyone,

I have a valid reference to a PowerPoint.Presentation object. I'd like to
programmatically create a macro and have that available during program
runtime.

As far as I can tell, this should do the trick:
currentPresentation.VBProject.VBComponents.Add(VBI DE.vbext_ComponentType.vbe
xt_ct_StdModule);
string s = "sub vbaSwitchToMaster()\r\n"+
"currentPresentation.Windows.Item(1).ViewType =
PowerPoint.PpViewType.ppViewTitleMaster\r\n"+
"end sub";
vbc.CodeModule.AddFromString(s);

Unfortunately, it does not.

In fact, this test line fails already:
Console.WriteLine(currentPresentation.VBProject);

Instead, this exception is being thrown (unfortunately):
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in WindowsApplication5.exe
Additional information: Exception from HRESULT: 0x80048240.

I am confused. Certainly, I would appreciate any sort of constructive
hint/suggestion/etc. which may shed some light on the matter.

Thanks in advance and best regards,

Alex Bendig
Nov 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.