Seite 1 von 1

PowerPoint: Makro über PB steuern

Verfasst: 01.08.2012 21:27
von Pelagio
Hallo :coderselixir: ,

mich interessiert im Augenblick welche Verknüpfungen ich in der einen oder anderen PowerPoint Präsentation habe.
Diesbezüglich habe ich auch ein VBA-Makro geschrieben:

Code: Alles auswählen

Private Sub Link_Look()
    Dim Praes As Presentation
    Dim Blatt As Slide
    Dim Bild As Shape
    
    Set Praes = ActivePresentation
    For Each Blatt In Praes.Slides
        For Each Bild In Blatt.Shapes
            If (Bild.Type = msoLinkedOLEObject) Then
                Debug.Print Bild.LinkFormat.SourceFullName
            End If
        Next
    Next
End Sub
Dies Makro muss ich nur in die jeweilige PowerPointDatei importieren und schon habe ich meine Information.
Da ich aber mehrere Dateien habe wollte ich über PB ein Programm schreiben in dem ich die PowerPointDatei aufrufen und
das Makro von PB aus über die Datei laufen lasse, um die Informationen mir anzuzeigen.
Ich habe mir gedacht ich versuche es einmal mit COMate aber irgendwie komme ich nicht zurande.
Vielleicht kann mir ja jemand von euch den entscheidenen Gedankenblitz zukommen lassen.
:praise:

Ich bin bis dato auf dieses Ergebnis gekommen, wobei ich mir nicht sicher bin ob es allen Tests standhalten würde.

Code: Alles auswählen

XIncludeFile "comateplus.pbi"

EnableExplicit

#pptFile = "test.ppt"

Global NewList gLinks.s()

Procedure ppLinks(vFile.s)
   Protected pApp.COMateObject          ; Application
   Protected pPres.COMateObject         ; Presentation
   Protected pSlides.COMateEnumObject   ; Slides
   Protected pShapes.COMateEnumObject   ; Shapes
   Protected pSld.COMateObject          ; Slide Object
   Protected pShp.COMateObject          ; Shape Object
   Protected pValue.s
   
   pApp = COMate_CreateObject("PowerPoint.Application")
   If pApp
      pPres = pApp\GetObjectProperty("Presentations\Open('" + vFile + "', #Optional, #Optional, #False)")
      If pPres
         pSlides = pPres\CreateEnumeration("Slides")
         If pSlides
            pSld = pSlides\GetNextObject()
            While pSld
               pShapes = pSld\CreateEnumeration("Shapes")
               If pShapes
                  pShp = pShapes\GetNextObject()
                  While pShp
                     If pShp\GetIntegerProperty("Type")  ;=?: msoLinkedOLEObject
                        pValue = pShp\GetStringProperty("LinkFormat\SourceFullName")
                        If pValue 
                           AddElement(gLinks())
                           gLinks() = pValue
                        EndIf
                     EndIf
                     pShp\Release()
                     pShp = pShapes\GetNextObject()
                  Wend
                  pShapes\Release()
               EndIf
               pSld\Release()
               pSld = pSlides\GetNextObject()
            Wend
            pSlides\Release()
         EndIf
         pPres\Invoke("Close")
         pPres\Release()
      Else
         Debug "!pPres"
         Debug COMate_GetLastErrorDescription()
      EndIf
      pApp\Invoke("Quit")
      pApp\Release()
   Else
      Debug "!pApp"
      Debug COMate_GetLastErrorDescription()
   EndIf
EndProcedure

ppLinks(#pptFile)

ForEach gLinks(): Debug gLinks(): Next

End

Re: PowerPoint: Makro über PB steuern

Verfasst: 11.08.2012 23:52
von Kiffi
Pelagio hat geschrieben:Ich habe mir gedacht ich versuche es einmal mit COMate aber irgendwie komme ich nicht zurande.
wo ist denn Dein genaues Problem?

Wenn Du die Konstante für msoLinkedOLEObject suchen solltest:

Code: Alles auswählen

#msoLinkedOLEObject=12
[...]
If pShp\GetIntegerProperty("Type") = #msoLinkedOLEObject
Grüße ... Kiffi