Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1632to1636
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
Grafik in PowerPoint Vorlage exportieren
18.07.2018 10:30:24
MArc
Halli hallo,
ich habe im Internet diesen funktionierenden Code gefunden. Jetzt würde ich gerne anstatt die Grafiken in eine leere PowerPoint, in eine Vorlage von mir kopieren die sich am desktop befindet. Leider weiß ich nicht an welchem Rad ich da drehen muss. Könnt mir da jemand bitte weiter helfen?
Option Explicit
Dim pptApp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSlide As PowerPoint.Slide
Dim pptSlideCount As Integer
Sub ChartsToPowerPoint()
Dim xSheet As Worksheet
Dim xChartsCount As Integer
Dim xChart As Object
Dim xActiveSlideNow As Integer
On Error Resume Next
For Each xSheet In ActiveWorkbook.Worksheets
xChartsCount = xChartsCount + xSheet.ChartObjects.Count
Next xSheet
If xChartsCount = 0 Then
MsgBox "Sorry, there are no charts to export!", vbCritical, "Ops"
Exit Sub
End If
Set pptApp = GetObject(, "PowerPoint.Application")
If pptApp Is Nothing Then
Set pptApp = CreateObject("PowerPoint.Application")
Set pptPres = pptApp.Presentations.Add
Set pptSlide = pptPres.Slides.Add(1, ppLayoutBlank)
Else
If pptApp.Presentations.Count > 0 Then
Set pptPres = pptApp.ActivePresentation
If pptPres.Slides.Count > 0 Then
xActiveSlideNow = pptApp.ActiveWindow.View.Slide.SlideIndex
Set pptSlide = pptPres.Slides(xActiveSlideNow)
Else
Set pptSlide = pptPres.Slides.Add(1, ppLayoutBlank)
End If
Else
Set pptPres = pptApp.Presentations.Add
Set pptSlide = pptPres.Slides.Add(1, ppLayoutBlank)
End If
End If
For Each xSheet In ActiveWorkbook.Worksheets
For Each xChart In xSheet.ChartObjects
Call pptFormat(xChart.Chart)
Next xChart
Next xSheet
For Each xChart In ActiveWorkbook.Charts
Call pptFormat(xChart)
Next xChart
Set pptSlide = Nothing
Set pptPres = Nothing
Set pptApp = Nothing
'MsgBox "The charts were copied successfully to the new presentation!", vbInformation, " _
KuTools For Excel"
End Sub
Private Sub pptFormat(xChart As Chart)
Dim xCharTiTle As String
Dim I As Integer
On Error Resume Next
xCharTiTle = xChart.ChartTitle.Text
xChart.ChartArea.Copy
pptSlideCount = pptPres.Slides.Count
Set pptSlide = pptPres.Slides.Add(pptSlideCount + 1, ppLayoutBlank)
pptSlide.Select
pptSlide.Shapes.PasteSpecial ppPastePNG
If xCharTiTle  "" Then
pptSlide.Shapes.AddTextbox msoTextOrientationHorizontal, 12.5, 20, 694.75, 55.25
End If
For I = 1 To pptSlide.Shapes.Count
With pptSlide.Shapes(I)
Select Case .Type
Case msoPicture:
.Top = 100
.Left = 250
.Height = 720
.Width = 400
Case msoTextBox:
With .TextFrame.TextRange
.ParagraphFormat.Alignment = ppAlignCenter
.Text = xCharTiTle
.Font.Name = "Tahoma (Headings)"
.Font.Size = 28
.Font.Bold = msoTrue
End With
End Select
End With
Next I
End Sub

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Eine PowerPoint Vorlage...
18.07.2018 11:05:17
Case
Hallo, :-)
... die auf dem Desktop gespeichert ist nutzen: ;-)
Set pptPres = pptApp.Presentations.Open(Environ("UserProfile") & "\Desktop\" & "TestVorlagePP2010.potx")
Name der Vorlage anpassen.
Servus
Case

Danke und eine weitere Frage
18.07.2018 14:36:24
Marc
Danke Case, es funktioniert =)
So ähnlich hatte ich es auch aber das hat mir gefehlt (Environ("UserProfile")
Ich hätte eine weitere Fragen. Aktuell wird die Vorlage geöffnet und für jede Grafik eine neue Seite erstellt. Ich würde jetzt aber gerne die Seiten der Vorlage nutzen. Sprich ich habe 4 Seiten in der Vorlage und ab der zweiten Seite soll eine Grafik nach der anderen rein kopiert werden.
Theoretisch müsste ich doch nur den Befehl löschen der dafür sorgt das immer eine neue Seite erstellt wird oder?
Kann mir da wer bitte weiterhelfen?
Anzeige
AW: Danke und eine weitere Frage
18.07.2018 22:22:52
Marc
Case kannst du mir da vll helfen?
Welche Folie Du nehmen...
19.07.2018 01:28:51
Case
Hallo, :-)
... musst, siehst Du prinzipiell hier: ;-)
PowerPoint...
Servus
Case

AW: Ich sehe nur schwarz
19.07.2018 17:06:39
Marc
Hm da finde ich mich ja noch schwerer zurecht =/
Aber danke vielleicht kommt noch die Erleuchtung
Als Informationsquelle für diese...
20.07.2018 06:53:24
Case
Hallo, :-)
... Fragen ist hier ein erster Anlauf: ;-)
Objektmodell (VBA-Referenz für PowerPoint)...
Da findest Du dann das "Slides-Objekt": ;-)
Slides-Objekt (PowerPoint)...
Da siehst Du, dass du die Slides z. B. mit dem Index ansprechen kannst: ;-)
ActivePresentation.Slides(1).Layout = ppLayoutTitle
Oder dem Namen: ;-)
ActivePresentation.Slides("Big Chart").Layout = ppLayoutTitle
Servus
Case

Anzeige

261 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige