简体   繁体   中英

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 (eg, 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM