Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
soha1902
Creator
Creator

Macro help

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.

5 Replies
Gysbert_Wassenaar

Perhaps this discussion helps: Re: Dynamic export


talk is cheap, supply exceeds demand
Anil_Babu_Samineni

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anil_Babu_Samineni

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
soha1902
Creator
Creator
Author

this code also exporting only unhide chart object. i want to export hide as well as unhide chart objects.

marcus_sommer

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