Extending Merge with your own VBA code .... MergeExtension
We frequently get requests for new Merge features. When they seem to be ideas that will be useful to more than just a few Merge users, we try to add them. But some users need features that might be useful only to them.
We can't always add these features to Merge. Instead we've added a feature called MergeExtension that enables you to extend Merge in all sorts of ways using external VBA code in specially named files.
The MergeExtension feature lets you run any arbitrary VBA code on each presentation that Merge generates, just before it saves the presentation.
You can write this code yourself, turn this documentation over to any competent VB/VBA programmer with at least some PowerPoint programming experience, or hire us to write it for you.
Note that we will help ensure that MergeExtension code runs but we can only support that we ourselves have written. We cannot help you debug code that you or someone else writes.
How it works
After creating each presentation but before saving it, Merge looks for an add-in file named:
- MergeExtension.PPAM if Merge is installed in PowerPoint 2007 and later
- MergeExtension.PPA if Merge is installed in PowerPoint 2003 or earlier
Merge looks first for this file in the same folder as the template file you're merging data into. If it doesn't find the file there,
it looks in the folder where Merge itself is installed.
If it finds the file in either place, it loads the add-in then calls a subroutine in the add-in named MergeExtension.
This subroutine looks like this:
Public Sub MergeExtension() ' Your code here End Sub
Important: This subroutine
- MUST be in the MergeExtension add-in
- MUST be named MergeExtension
- MUST be declared Public
You'll find an example MergeExtension.PPT file with instructions and code in the folder where Merge is installed. You can save it as an Add-in (PPAM or PPA or both) to test it. It simply adds a red rectangle with "MERGED" inside it to each slide that Merge creates.
You can store individually customized MergeExtension files with each of your merge templates if you wish; simply put each template in its own folder, with its own copy of your MergeExtension add-in.
Or you can have one MergeExtension file for all merges ... save your MergeExtension add-in in the folder that Merge is installed in.
Or both: Note that if you store a MergeExtension file in the Merge installation folder you can still put a MergeExtension file in one or more of the folders where your Merge templates are stored. Merge ALWAYS favors the MergeExtension file stored with the template that it's merging data into. In other words, you could have one general MergeExtension file and custom "override" files for certain merge template projects.
Why add-ins?
Why not use PPTM/PPT files with macros instead?
For one thing, users might open and meddle with the code in PPTM/PPT files. They can 't open PPAM/PPA (add-in) files.
But the main reason is that unless security is set to dangerously low levels, PowerPoint will issue macro warnings or simply disable the code in a PPTM/PPT file when it's opened. Either the warning dialogs will drive you crazy or it won't work at all. Neither's very acceptable.
This simply isn't a problem when the MergeExtension code is in add-in files.
Useful bits of example code
Public Sub MergeExtension() ' This one prints the presentation as it's merged With ActivePresentation.PrintOptions ' Print all slides in the presentation .RangeType = ppPrintAll ' Print one copy of each slide .NumberOfCopies = 1 ' Collate is only relevant if you're printing ' multiple copies, but here's how you set it up: .Collate = msoTrue ' Print slides as opposed to notes pages, etc: .OutputType = ppPrintOutputSlides ' Print all slides, hidden or not ' To skip hidden slides, change msoTrue to msoFalse .PrintHiddenSlides = msoTrue ' Uncomment one or the other to force printing in b/w or color ' or leave as is to accept PPT's defaults: '.PrintColorType = ppPrintColor '.PrintColorType = ppPrintBlackAndWhite ' Fill the page with the printout .FitToPage = msoTrue ' but don't add a frame around each slide .FrameSlides = msoFalse ' You can specify a particular printer here (by name) ' or leave this commented out to use the default printer: '.ActivePrinter = "hp LaserJet 1320 PS" End With ' And now that it's all set up, print it: ActivePresentation.PrintOut End Sub[Previous] [Home] [Next]