Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to Copy & Paste table into Powerpoint using paste special

Hello,

     I'm hoping someone has experience pasting tables into Powerpoint using paste special. I've had success using CopyToBitmapToClipboard using the following code:

ActiveDocument.GetSheetObject("CH418").CopyBitmapToClipboard

PPSlide.Shapes.Paste.Select

I would like to paste in an editable table instead of an image and I thought something like this code would work:

ActiveDocument.GetSheetObject("CH418").CopyTableToClipboard True

PPSlide.Shapes.PasteSpecial(PasteHTML).Select

However, I get the following error:

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

I confirmed that the Clipboard was not empty by manually pasting from it into Powerpoint. I also tried PasteDefault instead of PasteHTML.

The PasteSpecial works with CopyBitmapToClipboard. The example below worked so I think some form of PasteSpecial should work for straight tables:

ActiveDocument.GetSheetObject("CH418").CopyBitmapToClipboard

PPSlide.Shapes.PasteSpecial(PasteEnhancedMetafile).Select

If anyone has any insights, it would be greatly appreciated. I am using version 10.

thanx

Grant

24 Replies
alex_millan
Creator III
Creator III

Yes sachin,

it goes always to the second slide because the instruction marks the second slide.

You just have to adjust the instruction to point to the desired diapo. As example:

Set PPSlide = objPresentation.Slides(2)  '-->To point to the second slide

Set PPSlide = objPresentation.Slides(4)  '-->To point to the forth slide


HTH


Regards

sachingodhania
Contributor III
Contributor III

Hi Alex,

Sorry for typo, i mean to say the table always copies to slide 1 irrespective to the parameter you provide in obj.slides(eg 2).

The logic absolutely works fine with "CopyBitmapToClipboard" but not CopyTableToClipboard

Regards,

Sachin

sathishkumar_go
Partner - Specialist
Partner - Specialist

Hi,

While exporting the qlikview object into PPT, You have to maximize the qlikview object.

I don't know, you already did the same or not.. just to inform you to check these option.

-Sathish

alex_millan
Creator III
Creator III

Hi Sathish,

From my experience, there's no need to maximize the object, at least if it's not minimized in the app. If minimized, I haven't tested it. Did you notice any problem while not minimized?

Regards

sathishkumar_go
Partner - Specialist
Partner - Specialist

Hi Alex,

I have faced the issue for the minimized objects (But long time back). For minimized objects, we have to do maximize and export into ppt.

If its not minimized then same time you are keeping the multiple qlikview objects?

-Sathish

alex_millan
Creator III
Creator III

Thanks Sathish,

I've just tested,

indeed there's an issue while exporting a minimized object by using the bitmap option [.CopyBitmapToClipboard()],

however, the export works properly when using the table option [.CopyTableToClipboard(true)] on a minimized object.

Thanks for sharing, I didn't know this weird behaviour!

sachingodhania
Contributor III
Contributor III

Hi satish,

Yes i am doing that. Not sure what is the issue.

Regards,

Sachin

sachingodhania
Contributor III
Contributor III

Hi Alex,

Were you able to replicate the issue ? or its some thing wrong in my macro only.

Regards,

Sachin

alex_millan
Creator III
Creator III

Hi sachin,

try the following code:

     SUB ppt

     Const ppLayoutText = 2

     Set objPPT = CreateObject("PowerPoint.Application")

     objPPT.Visible = True

     Set objPresentation = objPPT.Presentations.Add

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

     ActiveDocument.GetSheetObject("CH03").CopyBitmapToClipboard

     PPSlide.Shapes.Paste

     Set PPSlide = Nothing

     Set PPSlide = objPresentation.Slides.Add(2, ppLayoutText)

     ActiveDocument.GetSheetObject("CH04").CopyBitmapToClipboard

     PPSlide.Shapes.Paste

     Set PPSlide = Nothing

     End Sub

This works fine on my test

Regards

alex_millan
Creator III
Creator III

Hi againg,

The following code saves the issue with the minimized objects, just in case you need it. If the object is minimized then restore it before Copy & Paste and then minimize it.

     SUB ppt

     Const ppLayoutText = 2

     Dim v

     v = 0

     Set objPPT = CreateObject("PowerPoint.Application")

     objPPT.Visible = True

     Set objPresentation = objPPT.Presentations.Add

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

     Set TargetObject = Activedocument.GetSheetObject("CH03")

     If TargetObject.IsMinimized Then

       v = 1

       TargetObject.Restore

     End If

     TargetObject.CopyBitmapToClipboard

     PPSlide.Shapes.Paste

     Set PPSlide = Nothing

     If v = 1 Then

       TargetObject.Minimize

       v = 0

     End If

     Set TargetObject = Nothing

     Set PPSlide = objPresentation.Slides.Add(2, ppLayoutText)

     Set TargetObject = Activedocument.GetSheetObject("CH04")

     If TargetObject.IsMinimized Then

       v = 1

       TargetObject.Restore

     End If

     TargetObject.CopyBitmapToClipboard

     PPSlide.Shapes.Paste

     Set PPSlide = Nothing

     If v = 1 Then

       TargetObject.Minimize

       v = 0

     End If

     Set TargetObject = Nothing

     End Sub

Regards