Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1444to1448
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Diagramm Powerpoint

Diagramm Powerpoint
28.08.2015 09:22:42
Gianni
Hallo Leute, ich möchte gerne meine Excel-Diagramme via Makro nach PowerPoint kopieren.
habe folgenden Code von dieser Seite
Sub CreatePPT()
Dim ppt As Object
Dim oPPT As PowerPoint.Application
Dim oPrs As PowerPoint.Presentation
Dim oSld As PowerPoint.slide
Dim oPct As PowerPoint.Shape
Dim oTxt As PowerPoint.Shape
Dim sPath As String
sPath = Application.DefaultFilePath & "/xl2ppt.ppt"
Set oPPT = CreateObject("PowerPoint.Application")
Set oPrs = oPPT.Presentations.Open("Dateiname+PFad")
Sheets("Diagramm2").Select
ActiveChart.ChartArea.Copy
Set oTxt = oSld.Shapes(1)
With oTxt
.Left = 50
.Top = 0
.Width = 650
.Height = 50
With .TextFrame
With .TextRange
With .Font
.name = "Arial"
.Size = 24
.Bold = msoCTrue
End With
End With
.AutoSize = ppAutoSizeShapeToFitText
End With
End With
With oTxt.AnimationSettings
.Animate = msoTrue
.EntryEffect = ppEffectBoxIn
.TextLevelEffect = ppAnimateByAllLevels
.AnimateBackground = msoTrue
.TextUnitEffect = ppAnimateByCharacter
.AdvanceMode = ppAdvanceOnTime
End With
Set oPct = oSld.Shapes.Paste(1)
oPrs.SaveAs sPath
oPrs.Close
Set oPct = Nothing
Set oTxt = Nothing
Set oSld = Nothing
Set oPrs = Nothing
Set oPPT = Nothing
Application.Wait Now + TimeSerial(0, 0, 3)
Set ppt = GetObject(sPath)
ppt.SlideShowSettings.Run
End Sub
Allerdngs kommt vor dem Abschnitt
With oTxt
.left......
der Laufzeitfehler "91"
hat einer einen Tipp?

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Diagramm Powerpoint
28.08.2015 09:27:11
Matthias
Hallo Gianni,
"Set oTxt = oSld.Shapes(1)"
Ich weis oSld wird am Ende geleert, aber wo wird es denn gefüllt?
lg Matthias

AW: Diagramm Powerpoint
28.08.2015 09:33:47
Gianni
Hallo Matthias,
das war die Standartform von der Website
StandardModule: Modul1
Sub CreatePPT()
Dim ppt As Object
Dim oPPT As PowerPoint.Application
Dim oPrs As PowerPoint.Presentation
Dim oSld As PowerPoint.Slide
Dim oPct As PowerPoint.Shape
Dim oTxt As PowerPoint.Shape
Dim sPath As String
sPath = Application.DefaultFilePath & "/xl2ppt.ppt"
Set oPPT = CreateObject("PowerPoint.Application")
Set oPrs = oPPT.Presentations.Add(msoCTrue)
Set oSld = oPrs.Slides.Add(1, ppLayoutTitleOnly)
oSld.Shapes.Title.TextFrame.TextRange.Text = "Diagramm-Test"
ActiveSheet.ChartObjects(1).Copy
Set oTxt = oSld.Shapes(1)
With oTxt
.Left = 50
.Top = 0
.Width = 650
.Height = 50
With .TextFrame
With .TextRange
With .Font
.Name = "Arial"
.Size = 24
.Bold = msoCTrue
End With
End With
.AutoSize = ppAutoSizeShapeToFitText
End With
End With
With oTxt.AnimationSettings
.Animate = msoTrue
.EntryEffect = ppEffectBoxIn
.TextLevelEffect = ppAnimateByAllLevels
.AnimateBackground = msoTrue
.TextUnitEffect = ppAnimateByCharacter
.AdvanceMode = ppAdvanceOnTime
End With
Set oPct = oSld.Shapes.Paste(1)
oPrs.SaveAs sPath
oPrs.Close
Set oPct = Nothing
Set oTxt = Nothing
Set oSld = Nothing
Set oPrs = Nothing
Set oPPT = Nothing
Application.Wait Now + TimeSerial(0, 0, 3)
Set ppt = GetObject(sPath)
ppt.SlideShowSettings.Run
End Sub

Da ich eine Datei-Vorlage öffne und alle Überschriften drin sind, habe ich die zwei Abschnitte gelöscht
Set oSld = oPrs.Slides.Add(1, ppLayoutTitleOnly)
oSld.Shapes.Title.TextFrame.TextRange.Text = "Diagramm-Test"
Wie könnte ich die Fehlermeldung umgehen?
Vielen Dank schonmal und Grüße
Grüße

Anzeige
AW: Diagramm Powerpoint
28.08.2015 09:48:11
Matthias
Dazu musst du für oSld einen Wert angeben. Da du keine neue Folie erstellen willst, kann du dabei einen festen Index oder Namen angeben.
Set oSld = oPrs.Slides(1)
Set oSld = oPrs.Slides("Folienname")
Such dir eine Zeile davon aus.
lg Matthias

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige