Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I want to export my chart into PPT. I have below requirement:
When I click on Export to PPT button chart 1 and Pivot table which appears below of chart 1 should be export to one slide and Chart 2 and pivot table which appears below of chart 2 should be export in second slide, like this I need to export 10 charts.
Please help me regarding this. I know I need to write MACRO for this. Anyone who have the good MACRO knowledge please help me.
Thanks
Hi Soha,
this my example, that allows me to export a few couple of objects, try to implement my example:
Sub ExportPPT
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objPresentation = objPPT.Presentations.Add
Set PPSlide = objPresentation.Slides.Add(1,11)
set up = ActiveDocument.GetApplication.GetUserPreferences
up.ChartUseCapNBorder = True
ActiveDocument.GetApplication.SetUserPreferences up
with objPresentation.Slides(1).Shapes(1)
.TextFrame.TextRange = "to powerpoint from access_point"
.Left = 100
.top = 15
.width=600
.height=20
end with
ActiveDocument.Sheets("SH02").Activate
ActiveDocument.GetSheetObject("CH04").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.PasteSpecial(PasteHTML)
.Left = 100
.top = 45
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH05").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 100
.top = 200
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH06").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 100
.top = 355
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH07").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 400
.top = 45
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH08").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 400
.top = 200
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH09").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 400
.top = 355
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("TX12").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 408
.top = 510
.width=80
.height=25
end with
Set PPSlide = Nothing
Set PPPres = Nothing
End sub
i hope that helps
beck
Hi Soha,
try this:
Sub ExportPPT
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objPresentation = objPPT.Presentations.Add
Set PPSlide = objPresentation.Slides.Add(1,11)
set up = ActiveDocument.GetApplication.GetUserPreferences
up.ChartUseCapNBorder = True
ActiveDocument.GetApplication.SetUserPreferences up
with objPresentation.Slides(1).Shapes(1)
.TextFrame.TextRange = "to powerpoint"
.Left = 100
.top = 15
.width=600
.height=20
end with
ActiveDocument.Sheets("YourSheet").Activate
ActiveDocument.GetSheetObject("YourChartID").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.PasteSpecial(PasteHTML)
.Left = 100
.top = 45
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("YourChartID").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 100
.top = 200
.width=100
.height=150
end with
Set PPSlide = Nothing
Set PPPres = Nothing
End Sub
I hope that helps
beck
Hi Beck,
Thanks for your reply..Your code will export one slide.I want this to be continue to be other charts also. It will automatically add more slides as per charts available. also please see below screenshot
Charts objects are overlapping in the PPT. I want it will be display inside the PPT with similar width of both the charts. Please help me.
Thanks
Hi Soha,
this my example, that allows me to export a few couple of objects, try to implement my example:
Sub ExportPPT
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objPresentation = objPPT.Presentations.Add
Set PPSlide = objPresentation.Slides.Add(1,11)
set up = ActiveDocument.GetApplication.GetUserPreferences
up.ChartUseCapNBorder = True
ActiveDocument.GetApplication.SetUserPreferences up
with objPresentation.Slides(1).Shapes(1)
.TextFrame.TextRange = "to powerpoint from access_point"
.Left = 100
.top = 15
.width=600
.height=20
end with
ActiveDocument.Sheets("SH02").Activate
ActiveDocument.GetSheetObject("CH04").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.PasteSpecial(PasteHTML)
.Left = 100
.top = 45
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH05").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 100
.top = 200
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH06").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 100
.top = 355
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH07").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 400
.top = 45
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH08").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 400
.top = 200
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("CH09").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 400
.top = 355
.width=100
.height=150
end with
ActiveDocument.GetSheetObject("TX12").CopyBitmapToClipboard
with objPresentation.Slides(1).Shapes.Paste
.Left = 408
.top = 510
.width=80
.height=25
end with
Set PPSlide = Nothing
Set PPPres = Nothing
End sub
i hope that helps
beck