How to mimic this presentation in PowerPoint VBA

I would like to have access to the document properties of the PowerPoint add-in file (presentation saved as "PowerPoint Add-in" (* .ppa) ", from some VBA code in the add-in itself.

If this helps to understand the problem, then what I'm actually trying to do is read the native property of the document, which stores the version number of the add-in, so that I can display this in the dialog box.

In Word and Excel, I can do this with ThisDocumentand ThisWorkbook, both of which return a link to a document containing the current code. However, there is no equivalent in PowerPoint ThisPresentation.

For a standard presentation or PowerPoint template, I could use ActivePresentation. However, this method will not work on the add-in.

Any ideas? Please no suggestions on where else should I stick with the version number :-)

+3
source share
3 answers

REVISED FEB 2, 2010: cleared answer to show only final decision


Here is a way to do what was set, not the DLLs. Really simple:

Sub ReturnPPAasPresentation()
    Dim p As Presentation
    Set p = Presentations("presentation1.ppa")
    Dim title As String, version As String
    version = p.CustomDocumentProperties("Version").Value
    title = p.BuiltInDocumentProperties("Title").Value
    MsgBox "Version: " & version & " of " & title, vbOKOnly, title
End Sub
0
source

, ThisPresentation PowerPoint. , . , , . ( "VBAProject" Project Explorer): , , , .

( MyProject ):

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
+2

macnerd nerd , AddIn. , AddIns VBProject, :

Function ThisPresentation(project_name As String) As Object
Dim p As Object

all_presentations = Array(Application.AddIns, Application.Presentations)
For Each pArray In all_presentations
    For Each p In pArray
        Debug.Print p.FullName
        If InStr(p.FullName, project_name) > 0 Then
            Set ThisPresentation = p
            Exit Function
        End If
    Next
Next
End Function
0

Source: https://habr.com/ru/post/1718472/


All Articles