Dynamically Generate PowerPoint in C++ .NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vipergt023
    New Member
    • Aug 2008
    • 27

    Dynamically Generate PowerPoint in C++ .NET

    Hi,

    Is there a way to dynamically generate a powerpoint file from scratch in C++ .NET? I'm running VS2008 and from what I've found supposedly Visual Tools for Office is already installed. The problem is I can't access any namespaces (e.g. PowerPoint, Microsoft.Offic e.Core, etc). Any ideas? Or do I have to create a generic powerpoint file and then populate it programmaticall y? Thanks.
  • pks00
    Recognized Expert Contributor
    • Oct 2006
    • 280

    #2
    there is vb.net code here http://www.codeproject.com/KB/vb/Pow..._in_VBNET.aspx which you could possibly adapt. Key thing here is the imports used. Given this you can do the equivalent in C++.net

    Comment

    • vipergt023
      New Member
      • Aug 2008
      • 27

      #3
      Thanks. I'll give it a try.

      Comment

      • vipergt023
        New Member
        • Aug 2008
        • 27

        #4
        I'm on the right track I think, but does anyone know how to set the text in a cell in a table on a powerpoint slide? This is what I'm doing...

        PpApp = gcnew PowerPoint::App lication();
        PpApp->Visible = MsoTriState::ms oTrue;
        PowerPoint::Pre sentations ^PpPresSet = PpApp->Presentation s;
        String ^val = WorkingDirector y + "\\wiips.po t";
        PowerPoint::Pre sentation ^PpPres = PpPresSet->Open(val,
        soTriState::mso False, MsoTriState::ms oTrue, MsoTriState::ms oTrue);
        PowerPoint::Sli des^ PpSlides = PpPres->Slides;
        PowerPoint::Sli de ^PpSlideImg = PpSlides->Add(1, PowerPoint::PpS lideLayout::ppL ayoutBlank);
        PowerPoint::Sli de ^PpSlideTbl = PpSlides->Add(2, PowerPoint::PpS lideLayout::ppL ayoutBlank);

        //get picture parameters
        int width = 0;
        int height = 0;
        GetPptPicSize(f ilename, &width, &height);
        PpSlideImg->Shapes->AddPicture(fil ename, MsoTriState::ms oFalse,
        MsoTriState::ms oTrue,
        (float)(MAX_WID TH + 20 - width)/2, (float)(MAX_HEI GHT + 20 - height)/2,
        (float)width, (float)height);

        PowerPoint::Sha pe ^tbl =
        PpSlideTbl->Shapes->AddTable(Csv Ds->Tables[0]->Rows->Count+1,
        CsvDs->Tables[0]->Columns->Count, 10, 10, MAX_WIDTH, MAX_HEIGHT);

        tbl->Table->Cell(1,1)->Shape->TextFrame->TextRange->Text = "hello";

        The problem is that for some reason C++ .NET in VS2008 doesn't have a member
        Text in the TextRange property. All the documentation says it does. What
        gives? Thanks.

        Vinoj

        Comment

        Working...