How to bundle my own images and call from function - vba

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)

Related

How can you add one of PowerPoint's built in Icons with 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).

PowerPoint Add-in directly access its object

Powerpoint file is actually a zip file that contains xml sub-files. These sub-files illustrate all the properties of objects of every slides (e.g., position, color, animation, etc.). You can convert the pptx file into zip file and unzip it you will see sub xml files.
Now, I want to create a Powerpoint Add-in application, allowing me to add more information to a specific object, and store dynamically it in itself XML file (or when saving file as). For example, my Add-in PowerPoint application contains a button named "Flippable". When I select a specific object of a slide, and select "Flippable", my application will find the xml file that contains the object information, and add a tag "Flippable = true".
Is it possible to do that dynamically when running application?
Thanks
Why go to all the effort of cracking and parsing the XML file, assuming that you even can while he presentation's open in PPT, especially since you're already doing this from an add-in?
You mentioned that the user has selected a shape. Why not just tag the shape:
With ActiveWindow.Selection.ShapeRange(1)
.Tags.Add "Flippable", "Yes"
End With
You'd want a bit more code around that to make sure that there IS a selection, and if you want to allow tagging multiple shapes at one time, you'd need to put in inside a For Each/Next loop.
Then assuming a reference to the current shape to be tested in oSh
If oSh.Tags("Flippable")="Yes" Then
' Do your stuff
End If

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...

Export Video from powerpoint using VBA

I want to export a video from powerpoint using VBA. This video was uploaded from the PC and not using links. I saw that this is possible for the images using this line of code:
ActivePresentation.Slides(1).Shapes(1).Export "C:\Cover.PNG", ppShapeFormatPNG
but I couldn't do the same for videos.
Do you simply need to extract the original video from the PPTX file? If so, rename the file to give it a .ZIP extension, open the zip file, browse for the media folder and in it, you'll find copies of any inserted (but not linked) sounds, videos and pictures.
If you have routines for working with ZIP files in VBA, you could probably work out how to do the same thing.
A possible alternative: size the video to fill the slide, then use PPT's SaveAs method to save as a WMV.

Using Office 2007 extension (i.e. docx) for skin based On-Screen keyboard

I'm creating a On-Screen keyboard for my application, and it supports skins as well.
Here's what I'm doing with the skins, I have a folder which contains some images and a xml file which maps the images to the keyboard, I want to be able to have the folder as a zip file like in Office 2007 (.docx) and iPhone firmwares (.ipsw), I know I can simply zip the folder and change the extension, what I need to know is how to read the files in the code.
You've got two options, either 1) just use a zip library like SharpZipLib or DotNetZip or 2) try to use the System.IO.Packaging namespace. I think option 1 would be the easiest probably.
There's nothing really magical that Office and other programs are doing, they're just reading a zip file and pulling stuff out of it as needed. Instead of pulling an image from a disk you just pull it from a MemoryStream.