programmatically creating powerpoint macro

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Bendig

    #1

    programmatically creating powerpoint macro

    Everyone,

    I have a valid reference to a PowerPoint.Pres entation object. I'd like to
    programmaticall y create a macro and have that available during program
    runtime.

    As far as I can tell, this should do the trick:
    currentPresenta tion.VBProject. VBComponents.Ad d(VBIDE.vbext_C omponentType.vb e
    xt_ct_StdModule );
    string s = "sub vbaSwitchToMast er()\r\n"+
    "currentPresent ation.Windows.I tem(1).ViewType =
    PowerPoint.PpVi ewType.ppViewTi tleMaster\r\n"+
    "end sub";
    vbc.CodeModule. AddFromString(s );

    Unfortunately, it does not.

    In fact, this test line fails already:
    Console.WriteLi ne(currentPrese ntation.VBProje ct);

    Instead, this exception is being thrown (unfortunately) :
    An unhandled exception of type 'System.Runtime .InteropService s.COMException'
    occurred in WindowsApplicat ion5.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


Working...