API: How to run SlideFab 2 from e.g. Excel via VBA

Through the SlideFab API it is possible to invoke the slide making automation from using VBA. This creates new possibilities, e.g. when SlideFab 2 is run through your VBA-based Excel add-in. SlideFab will run in a silent mode with no user interaction required such that there is a seamless integration possible.

It is important here that only the Slide Making mechanism is available in the API. Setting up the automation with the iteration loops, links between Excel and Powerpoint, etc., needs to be set upfront using the SlideFab 2 interface as always. Also the license key needs to be set up if SlideFab 2 is run as flex or saver instead of lite.

To run SlideFab from e.g. Excel using VBA it is required that PowerPoint is added as a reference within the VBA editor:

In the VB Editor go to Tools/References
Pick “Microsoft PowerPoint X.0 Object Library” from the list where X is the version you have installed. Confirm with OK.

Once the PowerPoint reference is made, a few lines of code are required to invoke SlideFab. The following method works in Excel, for example. It creates a Powerpoint application object and retrieves the SlideFab 2 add-in from it. The slide automation is invoked through the API with the method MakeSlidesFromWb.

Sub InvokeSlideFabMakeSlides()
    Dim addIn As COMAddIn
    Dim automationObject As Object
    Dim pptApp As PowerPoint.Application
    Set pptApp = CreateObject("PowerPoint.Application")
    Set addIn = pptApp.COMAddIns("HuehnSolutions.SlideFab2")
    Set automationObject = addIn.Object
    automationObject.MakeSlidesFromWb pptInputPath:="SomeTemplate.pptx", _
        wb:=ThisWorkbook, _
        pptOutputPath:="SomeOutput.pptx"
    pptApp.Quit
End Sub

The method MakeSlidesFromWb requires three parameters:

  1. pptInputPath as String: The relative or absolute path to the Powerpoint template presentation
  2. wb as Excel.Workbook: A reference to an existing Excel workbook
  3. pptOutputPath as String: The relative or absolute path where the created slides shall be written to