PowerPoint 2007 - Save images to a file? - vba

I was sent some PowerPoint 2007 files with approximately 75 slides in each. On each slide is one photo. I need to extract the photo from each slide to save in a folder on my system. How can it be achieved?

If for some reason you NEED to do the job using VBA, follow the link David's provided.
If it's a one-shot need to extract the images, make a copy of the PPTX file to begin with.
Let's call it COPY.PPTX for purposes of argument.
Rename COPY.PPTX to COPY.ZIP or even COPY.PPTX.ZIP
Now open the zip file, browse to the media folder and there you'll find the images in the file. Drag them out to wherever you want to store them and you're done.

For Each Slide in ActivePresentation.Slides
Slide.Shapes(1).Export FileName:="folderPath\imageName.jpg" _
Filter:=ppShapeFormatJPG
Next Slide

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

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)

Can I navigate a WebBrowser control to embedded image inside Excel file?

I have an .xlsm file with an ActiveX Microsoft Web Browser control ("Shell.Explorer.2").
I use VBA to open an image inside of it:
WebBrowser.Navigate Application.ActiveWorkbook.Path & "\image.gif"
I know that if I put an image on the worksheet it will be saved inside the .xlsm file. Such images are stored in the .xlsm (which is of ZIP structure) at \xl\media\ 'folder'.
Now I'd like to move the image from the workbook's path into the .xlsm file itself. How can I then address this image from the WebBrowser control? Should I navigate to a file inside of .xlsm as to resource or could I refer to a shape holding the image?
I know about solution based on copying (or exporting) the image from the shape and creating a dynamic HTML to include this newly copied image. I'd still like to find a way without copying/exporting it.
Thanks!

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

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.