ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Chart to PPT without opening PowerPoint (https://www.excelbanter.com/excel-programming/376782-chart-ppt-without-opening-powerpoint.html)

Abdul[_2_]

Chart to PPT without opening PowerPoint
 
By modifying the code available in this group now i can have each chart
sheet in seperate slides.

Is there a way that I can have this without activating powerpoint? when
i do this without activating I get only once slide..

Thanks


Sub Chart2PPT()

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PPShape As PowerPoint.Shape
Dim Fname As Variant
Dim CurTitle As Variant
Dim SlideCount As Long
Dim iCht As Chart

Set PPApp = CreateObject("Powerpoint.Application")
Set PPPres = PPApp.Presentations.Add

Application.ScreenUpdating = False
CurTitle = "XlChartToPPT"

Fname = ThisWorkbook.Path & Application.PathSeparator & CurTitle &
".ppt"

For Each iCht In ActiveWorkbook.Charts

iCht.CopyPicture xlScreen, xlPicture, xlScreen
SlideCount = PPPres.Slides.Count

Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.Visible = True
AppActivate PPApp.Name

With PPSlide

.Shapes.Paste
Set PPShape = .Shapes(.Shapes.Count)
PPShape.Left = 0#
PPShape.Top = 0#
End With
SlideCount = SlideCount + 1
Next iCht
With PPPres
.SaveAs Fname
.Close
End With

PPApp.Quit

Set PPApp = Nothing
Set PPPres = Nothing

End Sub


Mark Ivey

Chart to PPT without opening PowerPoint
 
Abdul,

I have been looking over your code. It does not transfer any information
over to the presentation. Is it still a work in progress?

I have been trying to find one I built a long time back...

I will post it as soon as I can find it.

--
Mark Ivey


"Abdul" wrote:

By modifying the code available in this group now i can have each chart
sheet in seperate slides.

Is there a way that I can have this without activating powerpoint? when
i do this without activating I get only once slide..

Thanks


Sub Chart2PPT()

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PPShape As PowerPoint.Shape
Dim Fname As Variant
Dim CurTitle As Variant
Dim SlideCount As Long
Dim iCht As Chart

Set PPApp = CreateObject("Powerpoint.Application")
Set PPPres = PPApp.Presentations.Add

Application.ScreenUpdating = False
CurTitle = "XlChartToPPT"

Fname = ThisWorkbook.Path & Application.PathSeparator & CurTitle &
".ppt"

For Each iCht In ActiveWorkbook.Charts

iCht.CopyPicture xlScreen, xlPicture, xlScreen
SlideCount = PPPres.Slides.Count

Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.Visible = True
AppActivate PPApp.Name

With PPSlide

.Shapes.Paste
Set PPShape = .Shapes(.Shapes.Count)
PPShape.Left = 0#
PPShape.Top = 0#
End With
SlideCount = SlideCount + 1
Next iCht
With PPPres
.SaveAs Fname
.Close
End With

PPApp.Quit

Set PPApp = Nothing
Set PPPres = Nothing

End Sub



Mark Ivey

Chart to PPT without opening PowerPoint
 
Abdul,

After thinking about it...

I think you still need to open the presentation for this to work, but you
can set the visible properties to false to prevent the user from seeing what
is going on.

--
Mark Ivey

UoP e-mail:
Personal e-mail:

"Abdul" wrote in message
ps.com...
By modifying the code available in this group now i can have each chart
sheet in seperate slides.

Is there a way that I can have this without activating powerpoint? when
i do this without activating I get only once slide..

Thanks


Sub Chart2PPT()

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PPShape As PowerPoint.Shape
Dim Fname As Variant
Dim CurTitle As Variant
Dim SlideCount As Long
Dim iCht As Chart

Set PPApp = CreateObject("Powerpoint.Application")
Set PPPres = PPApp.Presentations.Add

Application.ScreenUpdating = False
CurTitle = "XlChartToPPT"

Fname = ThisWorkbook.Path & Application.PathSeparator & CurTitle &
".ppt"

For Each iCht In ActiveWorkbook.Charts

iCht.CopyPicture xlScreen, xlPicture, xlScreen
SlideCount = PPPres.Slides.Count

Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.Visible = True
AppActivate PPApp.Name

With PPSlide

.Shapes.Paste
Set PPShape = .Shapes(.Shapes.Count)
PPShape.Left = 0#
PPShape.Top = 0#
End With
SlideCount = SlideCount + 1
Next iCht
With PPPres
.SaveAs Fname
.Close
End With

PPApp.Quit

Set PPApp = Nothing
Set PPPres = Nothing

End Sub





All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com