Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Empty clipboard error when exporting charts to Powerpoint

I am trying to get the folling macro to export charts to Powerpoint:

Sub ppt

'An array with the objects you want to export to powerpoint

Dim myArray(21)

myArray(0) = "CH1424"

myArray(1) = "CH1465"

myArray(2) = "CH1430"

myArray(3) = "CH1428"

myArray(4) = "CH1416"

myArray(5) = "CH1414"

myArray(6) = "CH1412"

myArray(7) = "CH1410"

myArray(8) = "CH1055"

myArray(9) = "CH1054"

myArray(10) = "CH1053"

myArray(11) = "CH1051"

myArray(12) = "CH1050"

myArray(13) = "CH1049"

myArray(14) = "CH1048"

myArray(15) = "CH1089"

myArray(16) = "CH1046"

myArray(17) = "CH1045"

myArray(18) = "CH1044"

myArray(19) = "CH2992"

myArray(20) = "CH1043"

myArray(21) = "CH1432"

'Create ppt object

Set PPApp = CreateObject("PowerPoint.Application")


PPApp.Visible = True

Set objPresentation = PPApp.Presentations.Add


'Apply a template if you want one

'objPresentation.ApplyTemplate _

' ("C:\mytemplate.potx")


'For each object in the array create a new slide and paste it.

For each item in myArray


Set PPSlide = objPresentation.Slides.Add(1,1)

Set v=ActiveDocument.GetVariable("PRINT")
v.SetContent "Y",true
ActiveDocument.GetSheetObject(item).restore
ActiveDocument.GetSheetObject(item).CopyBitmapToClipboard
ActiveDocument.GetSheetObject(item).minimize
v.SetContent "N",true

PPSlide.Shapes.Paste


Next


'Clean up

Set PPSlide = Nothing

Set PPPres = Nothing

Set PPApp = Nothing


End Sub

I can get it to work 1 time.  When I try it again, I get the following error message:

Shapes.Paste : Invalid request. Clipboard is empty or contains data which may not be pasted here.

3 Replies
Not applicable
Author

Hi Swenzel

did you get an answer to this ? I have a similar problem ...

regards

Ian

m_woolf
Master II
Master II

Does this work with a smaller set of charts in the array?

When you restore these charts manually, do they take a while to open?

You might try:

     Application.WaitForIdle

after the chart restore line

Not applicable
Author

This code works when Requested Module Security = System Access and Current Local Security = Allow System Access. QV11 SR1

Sub pptSFNY

'An array with the objects you want to export to powerpoint

Dim myArray(8)

myArray(0) = "CH3509"

myArray(1) = "CH3410"

myArray(2) = "CH3330"

myArray(3) = "CH3326"

myArray(4) = "CH3325"

myArray(5) = "CH3323"

myArray(6) = "CH3321"

myArray(7) = "CH3319"

myArray(8) = "CH3434"

'Create ppt object

Set PPApp = CreateObject("PowerPoint.Application")

PPApp.Visible = True

Set objPresentation = PPApp.Presentations.Add

'Apply a template if you want one

'objPresentation.ApplyTemplate _

' ("C:\mytemplate.potx")

'For each object in the array create a new slide and paste it.

For each item in myArray

Set PPSlide = objPresentation.Slides.Add(1,11)

Set v=ActiveDocument.GetVariable("PRINT")

v.SetContent "Y",true

ActiveDocument.GetSheetObject(item).restore

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.GetSheetObject(item).CopyBitMapToClipboard

ActiveDocument.GetSheetObject(item).minimize

v.SetContent "N",true

PPSlide.Shapes.Paste

Next

'Clean up

Set PPSlide = Nothing

Set PPPres = Nothing

Set PPApp = Nothing

End Sub