Ich habe ein Modul geschrieben, welches automatisch mehrere PowerPoint-Präsentationen zusammenfügt und Excel-Bereiche zusätzlich einfügt.
Nun habe ich aber das Problem, dass mein Makro in Office 13 und Office 16 problemlos laufen muss! Daran scheitere ich gerade.
Ich habe versucht, die Verweise per VBA automatisch zu setzen.
Sub Ref15()
Dim lng_Count As Long
Dim bln_Reference As Boolean
'Add Microsoft Powerpoint 15.0 Object Library
On Error GoTo Object16
bln_Reference = False
With Application.VBE.ActiveVBProject.References
For lng_Count = 1 To .Count
If .Item(lng_Count).GUID = "{91493440-5A91-11CF-8700-00AA0060263B}" Then
If .Item(lng_Count).IsBroken Then
.Remove .Item(lng_Count)
Else
bln_Reference = True
Exit For
End If
End If
Next
If bln_Reference = False Then
.AddFromGuid GUID:="{91493440-5A91-11CF-8700-00AA0060263B}", Major:=2, Minor:=0
End If
End With
Exit Sub
Object16:
Ref16
End Sub
Sub Ref16()
Dim lng_Count As Long
Dim bln_Reference As Boolean
'Add Microsoft Powerpoint 16.0 Object Library
On Error GoTo ReferenceMsg
bln_Reference = False
With Application.VBE.ActiveVBProject.References
For lng_Count = 1 To .Count
If .Item(lng_Count).GUID = "{91493441-5A91-11CF-8700-00AA0060263B}" Then
If .Item(lng_Count).IsBroken Then
.Remove .Item(lng_Count)
Else
bln_Reference = True
Exit For
End If
End If
Next
If bln_Reference = False Then
.AddFromGuid GUID:="{91493441-5A91-11CF-8700-00AA0060263B}", Major:=2, Minor:=0
End If
End With
Exit Sub
ReferenceMsg:
MsgBox "An Error occured!" & vbNewLine & "Please open the VBA editor and activate the _
reference ""Microsoft Powerpoint 15.0 Object Library"" or ""Microsoft Powerpoint 16.0 Object Library"".", vbCritical + vbOKOnly, "Reference Error"
End Sub
Allerdings läuft das Ganze nicht immer zuverlässig! Ich konnte aber nicht herausfinden, wann es funktioniert und wann nicht. :PIch brauche die Verweise, weil ich danach noch auf die PowerPoint-Objekte zugreife. Oder kann ich das auch ohne Verweise realisieren?
Dim oPPT As PowerPoint.Application
Dim oPPTFinal As PowerPoint.Presentation
Dim oPPTPres As PowerPoint.Presentation
Dim oPPTSlide As PowerPoint.Slide
'Folgende Befehle verwende ich ua
Set oPPTFinal = oPPT.ActivePresentation
int_i = oPPT.ActivePresentation.Slides.Count
oPPT.ActivePresentation.Slides.Range(arr_Slides).Copy
oPPTFinal.Slides.Paste
oPPT.ActivePresentation.Close
Set oPPTSlide = oPPT.ActivePresentation.Slides.Add(int_j, ppLayoutTitleOnly)
oPPTSlide.Shapes(1).TextFrame.TextRange.Text = "STRING"
Ich hoffe, ich habe mich verständlich ausgedrückt. Wenn nicht, bin ich gerne bereit Gegenfragen zu beantworten!Vielen Dank!
LG
ZD14