Placing a bitmap into a Powerpoint Add-In - vba

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

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 Macro in a template

I am currently working on creating a template for a business presentation.
After the current client's name is written in the starting slide I want to be able to take it and place it on X amount of slides later created via a template, so that manual entry is almost completely reduced (this is a prerequest for the task).
Is it possible to create a macro so that it either edits the template slides after the needed information is written on the 1st slide or that it controls all the user created slides and labels afterwards?
What you're after is possible so long as the user can either install an add-in that you've written to do the job or open a file that you've saved as a PPTM rather than PPTX (ie, one with macros/vba included).

Found an OfficeDraw file with shapes. Can the shapes be used without continuous copy-and-paste?

I downloaded an OpenOffice Draw document with shapes I want to use (for drawing Apache Camel diagrams). I'm not very familiar with Draw, but I've used Visio; in Visio, there was a kind of file in which you could find/put shapes, then use to create drawings from those shapes. The shapes appeared in a panel left of and smaller than the drawing, and you could drag a shape from that panel to the drawing to put an instance of that shape on your drawing; the original shape remained on the smaller panel.
I think Visio called the file that held the shapes you could use a "template"; Draw has templates, but I haven't found a reference to them holding shapes to drag onto a drawing. I've tried looking it up, but am hampered by not knowing what terms Draw uses for these things. Can someone tell me whether this is possible in Draw, and what things I should look up help on? I hate to read a whole manual to find out how to use one feature, without even knowing if the feature exists...
--
I'm sorry, I should have done better describing what I have tried. The file holding the shapes is an odg file; it opens fine as a document, and the program allows me to save it as a template, but the behavior of being a collection of shapes that I can drag onto a new drawing repeatedly, without having to copy a shape each time, is not there. That's the feature I'm trying to find.
My version (LO 5.2.3.3/openSuse) allows the creation of a new shape gallery theme (see: View>Clipart Gallery), and the addition of various graphic format files to that theme.
Also, in context meni of a shape, I can edit with external program.
So, I guess, you can save the shape(s) in a file and add it to My Shapes theme.
There will be two new files in ~/.config/libreoffice/5/user/gallery with the shape(s), to backup/restore (to a new installation) or distribution (to other computers).
Edit if your version of the office suite is lacking of that menu options, maybe you can extract the shapes from the *.odg file: unzip it and look for a custom *.sdv and *.thm file in the archive.

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.