5

My goal is to ensure that the C++ code I insert in my presentation compiles correctly. I therefore thought I'd have each example in a separate file (so that I can compile it), and include the text from those files in the Powerpoint slides... I want this 'inclusion' to be dynamic, so that if I change the code in a file, the slides are automatically updated.

Is it possible? Will I have to use LaTeX instead of Powerpoint? Any other suggestion about how to solve this problem?

Thanks.

4 Answers4

1

In PowerPoint you will need to write a macro to read the text and update the slide.

An example of a macro to read a text file can be found here:
Read in text from an ascii file.

You will also need to force the slide to refresh:

' assuming a reference to the current slide in oSl
ActiveWindow.View.GotoSlide(oSl.SlideIndex)

This article could also be useful as an example :
Add a random phrase from a text file to a text box on each slide

harrymc
  • 498,455
1

See this question. You don't need code to get the slide to update if you insert it as an object

Powerpoint 2007 linking to external content

Rhys Gibson
  • 4,618
1

If you rename a Powerpoint 2010 .pptx file into a .zip file, you can open it via Winzip, 7zip etc.

The slide contents are written in XML files named "...\ppt\slides\slide2.xml" in this packed archive structure.

A snippet from a German .pptx file:

-<a:p>
-<a:r>
<a:rPr lang="de-DE" smtClean="0" err="1" dirty="0"/>
<a:t>A text to change ....</a:t>
</a:r>
-<a:r>
<a:rPr lang="de-DE" smtClean="0" dirty="0"/>
<a:t> </a:t>
</a:r>
-<a:r>
<a:rPr lang="de-DE" smtClean="0" err="1" dirty="0"/>
<a:t>another Text to change</a:t>
</a:r>
-<a:r>
<a:rPr lang="de-DE" smtClean="0" dirty="0"/>
<a:t> </a:t>
</a:r>
-<a:r>
<a:rPr lang="de-DE" smtClean="0" err="1" dirty="0"/>
<a:t>Text ...</a:t>
</a:r>
-<a:r>
<a:rPr lang="de-DE" smtClean="0" dirty="0"/>
<a:t> </a:t>
</a:r>
-<a:r>
<a:rPr lang="de-DE" smtClean="0" err="1" dirty="0"/>
<a:t>Text ...</a:t>
</a:r>
<a:endParaRPr lang="de-DE" smtClean="0" dirty="0"/>
</a:p>

So, it should be possible to prepare a .pptx template file and replace placeholder strings like ${Text1234} using a home-grown tool.

Axel Kemper
  • 4,038
0

I don't know if there is an API which will allow you to code in C++ directly, but there is one for Java: poi.apache.org so you could always wrap in it in a script to execute it.

That said, LaTex sound like a better fit IMHO.

totaam
  • 2,024