Hvordan åbner man en ny powerpoint præsentation fra excel?
Hej Eksperter.Jeg skal kopiere en graf fra excel til en ny powerpoint applikation.
Jeg har allerede en makro der kan kopiere grafen til en åben powerpoint applikation, så jeg skal bare finde ud af hvordan jeg med VBA kan åbne en sådan. Så kan jeg sætte min eksisterende makro i halen på den.
Den eksisterende makro ser sådan ud:
---------------------------------------
Sub macro1()
' Set a VBE reference to Microsoft PowerPoint 8.0 Object Library for Office 97,
' or Microsoft PowerPoint 9.0 Object Library for Office 2000.
' NOTE: I have only tested this in Office 97.
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
' Make sure a chart is selected
If ActiveChart Is Nothing Then
MsgBox "Please select a chart and try again.", vbExclamation, _
"No Chart Selected"
Else
' Reference existing instance of PowerPoint 97
Set PPApp = GetObject(, "Powerpoint.Application.8")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide = PPPres.Slides _
(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
' Copy chart as a picture
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, _
Format:=xlPicture
' Paste chart
PPSlide.Shapes.Paste.Select
' Align pasted chart
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End If
End Sub
-------------------------------
Håber I kan hjælpe.
Med venlig hilsen Lasse
