How can you add one of PowerPoint's built in Icons with VBA? - vba

I don't see any methods in the PowerPoint Object Model to add one of PowerPoint's built in icons. I see the ability to add the built in shapes and pictures, but not icons?
How would you do it? Would it be best to just have a slide with the icons I want to use saved somewhere and just copy it off the slide?

It seems that upon looking into the problem further PowerPoint does not have the ability to insert its built in icons using VBA. Additionally, when creating a PPAM file from a PPTM you lose all slides, masters, layouts, etc.
The best way to insert slides or objects on slides is to just create another PPTX file and store it on SharePoint, a share drive, or just distribute a file with your add-in so that you can reference the slides and objects on the slides in your add-in.
The Slides.InsertFromFile method requires a filename and index. The filename is a string and while the example shows a local resource I have tested and it also works with an internet URI (specifically tried a SharePoint resource, but I could do further testing if needed).

Related

How to bundle my own images and call from function

I have built several custom add-ins for Powerpoint. I integrated them into PPT using Custom UI Editor for Office.
As part of this process, I could make my own icons for buttons, simply by 'Inserting' my own .png files into the PPT (presumably somewhere in the backend, if I were to unbundle the .zip. file which every PPT actually is.
Now, I want to create a button that allows users to easily insert country flag icons, which I can obtain in .svg format. How can I bundle these .svg or .png files into PPT, and call them from a module?
(I don't think it's the calling from module I have trouble with - I just don't know how to bundle the image files into the PPT.)
[EDIT] Alternatively, what I'm asking is this: How can I create an 'Insert Icons' interface that looks like what you get from Insert >> Icons?
(update: John Korchok's answer has made clear this is not possible)
[EDIT2] If you rename your powerpoint from .pptm to .zip```, you can see a folder inside the Zip file called ```ppt. Inside it, you get these folders:
Inside the media folder are EMF and WMF files created from pictures that were inserted into PPT (through the normal Insert Image function, or a simple Copy and Paste).
Is there a way I can write a function that calls images from within this folder?
There's no part of an Add-in where you might be able to store external files. I add a folder of images in the Add-ins folder, then create an installer that places the Add-in and folder in the correct locations.
You can also place the images on a web server and get PowerPoint to download them through VBA. Of course, you'll need a fast connection. The syntax looks like this:
Dim oPicture As Shape
Set oPicture = ActivePresentation.Slides(1).Shapes.AddPicture("http://www.brandwares.com/images/iconfile.png", False, True, 0, 0, -1, -1)

Placing a bitmap into a Powerpoint Add-In

All:
I am writing a PowerPoint add-in that will allow a user to drop specific safety related images onto a map. I've written the code that copies the images and places them on the slide and I would like to place it into an add-in. Unfortunately, I cannot find a way to either:
a) place the images into the add-in
b) reference images if I were able to place them in the add-in
The alternative approach is to require the user to start with a special template that includes all of the images and then load the add-in to get the menu functionality. I would much rather have a single file that contains both the code and bitmap images.
With best regards,
Walt
PPA files contain only code, not presentation content like images. As an alternative, you could distribute a PPT/PPTX that you open invisibly and extract the image you need.
After quite a bit of looking around I found a solution that resolves the problem adequately. Using Microsoft's Custom UI Editor, I created an XML entry in the PowerPoint Presentation that performs the Auto_Open function that would have been part of the Add-In. This allows me to add the menu functions that will be responsible for loading the specific images.
I've added a reference page at the beginning of the presentation that contains instructions on how to use the template... This page also contains all of the images that are used by the visual basic code. The 'Visible' flag on these images are set to False so the user does not see them. As they are copied from the reference page into the presentation, the Visible flag is set to True and they are pasted onto the current slide.
It is not a perfect solution, but it is adequate...

How to save options of a VSTO add-in in the currently open file?

I'm building a VSTO add-in for Powerpoint 2010 and the options the add-in sets apply to the currently open file instead of a per-user config. Can I save these options in the current file (I mean, add custom XML to the .PPTX file)? If so, how?
Thanks for your help.
For very simple data, custom properties are ok (so long as you're aware that anyone who opens the file will be able to see, edit and delete them). And note that because PPT shares a common, too-small, allocation of data between links and document properties, adding too many of one can wipe out the other.
I'd use tags instead. Every shape, slide and presentation object can have a tags collection, containing one or more Name / Value pairs of strings.
These are invisible to the user and will not interfere with the hyperlinks in the presentation.
' To add a tag
With ActivePresentation
.Tags.Add "MyTagName", "MyTagValue"
End With
' To use a tag
If ActivePresentation.Tags("MyTagName") = "MyTagValue" Then
' Do something or other
End If
If your Options are not too complex, I would go for Document Custom Properties. The following question illustrates how to use Custom Properties with Excel, they are supported in PowerPoint as well so this should provide a good starting point!

PowerPoint Programmatically open/play mediaobject in add-in

I am working on a VSTO PowerPoint 2010 add-in which will allow the user to playback a media object (video or audio) in a windows form using windows media player control.
In which way can I extract the embedded media object an play it back to the user?
I have access to the objects name, will that be enough to get to the embedded object?
Kinda yes and no.
The "No". Through VBA and VSTO, the answer is no or at least I've never seen it done before and have no idea. I've looked at this before and didn't find it to be possible.
The "Kinda Yes". Any embedded media in 2007/2010 can be extracted through Open XML. Here's where the "kinda" comes in - you can extract it so long as you know what you're extracting. Sounds easy enough, but it's not. When you insert a video or audio piece, it gets embedded into a shape. That shape is given a name[1], which is the file name of the audio/video file. So if I insert the sample video that comes with Win7, my shape name that holds the video is "wildlife.wmv". It can easily be renamed by an end user who knows how to do so (the Selection Pane in the client) and in that case, it would be impossible to find based on just having the name.
But if it hasn't been renamed, you would open an in-memory copy of your .pptx in Open XML, search on the name in each of the slides in the /ppt/slides/ folder and once found, use it's relationship Id to locate it's name in the /ppt/media folder. Then you can pull it out, save it to disk, play it, etc.
1 PowerPoint, however, renames the file based on an internal naming convention. My "wildlife.wmv" is renamed "media1.wmv" inside the package. Subsequent media items would be named media2.wmv, media1.mpg, etc.

Is it possible to have PowerPoint 2007 export slides to a PDF including animations?

I'm exporting PowerPoint presentations using PowerShell. This works fine with the Office XPS/PDF exporter plugin. However, only the complete slide, without animations, are exported.
When exporting a presentation as a web page, the presentation can be run step-by-step (e.g. revealing bullet points one by one) if you check the "Show slide animation while browsing" option (under "Web options").
Is there any way to generate a PDF with one page per animation step in the presentation, through scripting? (If not - any tips on how to do it in general?)
When exporting to PDF it will export simple text and images so animation are not there :(
For method to generate a page per animation, you will have to explore Powerpoint object model and use some PDF generation library like iTextSharp to out put all transitions one by one.
The Powerpoint Object model is here