Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have 10 charts in a single QV sheet. I displayed one chart at a time and conditional hide/show the remaining charts.
Now I want to export all 10 charts in the PPT. Can any one let me know the macro for this. I am able to export the unhide chart in the PPT but not able to export hide charts.
Is there any property or function where I can check whether chart object is hide or unhide, if it is hide then unhide it, export to PPT and again hide it.
Please help me regarding this.
Perhaps this discussion helps: Re: Dynamic export
You Might need to try for all charts using button Macro
Sub exportAllCharts
Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
Set PPPres = PPApp.Presentations.Add
for j = ActiveDocument.NoOfSheets - 1 to 0 Step -1
set ss= ActiveDocument.GetSheet(j)
shName=ss.GetProperties.Name
'msgbox(shName & " - j:" & j ) ' NOTE: IF I UNCOMMENT THIS LINE IT WORKS
ActiveDocument.Sheets(j).Activate
ActiveDocument.GetApplication.WaitForIdle
set s=ActiveDocument.ActiveSheet
charts=s.GetGraphs
for i=ubound(charts) to lbound(charts) step -1
ActiveDocument.GetApplication.WaitForIdle
Set PPSlide = PPPres.Slides.Add(1, 1)
PPSlide.Shapes(1).Delete ' removes the title
PPSlide.Shapes(1).Delete ' removes the text box
ActiveDocument.GetSheetObject(charts(i).getobjectid).CopyBitmapToClipboard
PPSlide.Shapes.Paste
next
next
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
MSGBOX "PowerPoint export is complete!", vbInformation,"PPT Export"
End Sub
You Might need to try for all charts using button Macro
Sub exportAllCharts
Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
Set PPPres = PPApp.Presentations.Add
for j = ActiveDocument.NoOfSheets - 1 to 0 Step -1
set ss= ActiveDocument.GetSheet(j)
shName=ss.GetProperties.Name
'msgbox(shName & " - j:" & j ) ' NOTE: IF I UNCOMMENT THIS LINE IT WORKS
ActiveDocument.Sheets(j).Activate
ActiveDocument.GetApplication.WaitForIdle
set s=ActiveDocument.ActiveSheet
charts=s.GetGraphs
for i=ubound(charts) to lbound(charts) step -1
ActiveDocument.GetApplication.WaitForIdle
Set PPSlide = PPPres.Slides.Add(1, 1)
PPSlide.Shapes(1).Delete ' removes the title
PPSlide.Shapes(1).Delete ' removes the text box
ActiveDocument.GetSheetObject(charts(i).getobjectid).CopyBitmapToClipboard
PPSlide.Shapes.Paste
next
next
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
MSGBOX "PowerPoint export is complete!", vbInformation,"PPT Export"
End Sub
this code also exporting only unhide chart object. i want to export hide as well as unhide chart objects.
You can't export hidden objects. That's meant you need to make them visible at first, then export them and after that you restored the original visibility of the objects. For this you could change the visibility-condition of each object within your loop - it will depend on the way you set the condition if you need to change one or several variable-values or if you need to switch between different selections.
- Marcus