I would like to be able to access the document properties of a PowerPoint add-in file (a presentation saved as "PowerPoint Add-in (*.ppa)", from some VBA code in the add-in itself.
If it helps to understand the problem, what I'm actually trying to do is read a custom document property that stores the version number of the add-in, so that I can display that in a dialog box.
With Word & Excel I can do this using ThisDocument
& ThisWorkbook
, both of which return a reference to the document containing the running code. However, there is no ThisPresentation
equivalent in PowerPoint.
For a standard PowerPoint presentation or template, I could use ActivePresentation
. However, this method won't work for an add-in.
Any ideas? Please, no suggestions about where else I should stick the version number :-)
Like everyone else I expected a ThisPresentation object in PowerPoint. I thought of another way to accomplish it, without a hardcoded filename. Obviously any piece of code would need to know how to distinguish between the projects. I chose to use the projectname for this (default name "VBAProject" in the Project Explorer): it is not used for anything else, no user will change it and if it is protected they can't.
Here is my code (change MyProject into your own projectname):
Function ThisPresentation() As Presentation
Dim p As Presentation
For Each p In Presentations
If p.VBProject.Name = "MyProject" Then
Set ThisPresentation = p
Exit Function
End If
Next
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With