Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Copy container as a picture

Hello all,

is it possible to copy a container an all objects in as a picture?

There is an option, but does'nt seems to work:

2012-08-16_124550.png

Thanks

Laurent

6 Replies
chematos
Specialist II
Specialist II

I never tried it but may be with a macro?

There are a lot of examples to crear an Excel Application object and copy-paste objects, the next two lines are to get the object container, you need to use the ID of your container "CTXX" and copy the object as bitmap but I´m not sure that this works with a container... you could use with the charts inside the container.

Set ContainerObj= ActiveDocument.GetSheetObject("CT01") '         

      ContainerObj.CopyBitmapToClipboard true

hope this helps

Not applicable
Author

Thanks for your suggestion.

I had already try it but without success.

To copy chart inside container via macro, need to activate and restore the container before copying chart.

Something like this:

set ContainerObj = ActiveDocument.GetSheetObject("CTXX")

    ContainerObj.GetSheet().Activate()         

    ContainerObj.Restore

    set objSource = ActiveDocument.GetSheetObject("CHXXX")

    objSource.Restore

    ActiveDocument.GetApplication.WaitForIdle

    objSource.CopyBitmapToClipboard()

Regards

chematos
Specialist II
Specialist II

I didn´t know that, do you know what is the behaviour of functions Activate, Restore and WaitForIdle?

I´m glad to be helpfull, I hope you get the full solution

Regards

Not applicable
Author

"ContainerObj.GetSheet().Activate()  " is to activate the sheet where the Object is in. Essential before select the object itself.

"Restore" is like maximise and minimise the object but on the sise defined in properties, tab>legend

"WaitForIdle" is just to wait the refresh or calculating of the table or chart is done before copying it.

To export into excel file, my base was the very good work of Stefan Walther:

http://www.qlikblog.at/971/qliktip-32-exporting-multiple-objects-single-excel-document/#comment-7583...

Regards

chematos
Specialist II
Specialist II

Amazing!!

masselin
Contributor II
Contributor II

Hi!

I have the same need and I had the same disappointing discovery of one of the few Qlikview bugs :

copybitmaptoClipboard does not work on containers !!!

I work out a turn around this way :

a: create a button

b: assign external / macro

c: use the following code

 

sub Container_copy

Dim obj

Dim fso

set obj = ActiveDocument.GetSheetObject("CT03")

  • obj.ExportBitmapToFile "c:\MyImage2.bmp"

Set objIE = CreateObject("InternetExplorer.Application")

  • objIE.Navigate("c:\MyImage2.bmp")

Set WShell = CreateObject("WScript.Shell")

  1. WShell.sendkeys "^a^c"

'WScript.Sleep 250

  1. WShell.SendKeys "%{F4}"

Set fso = CreateObject("Scripting.FileSystemObject")

  1. fso.DeleteFile("c:\MyImage2.bmp")

set obj = nothing

set fso = nothing

end sub

This copies container image to a file and then opens the file in MSpaint / select it / copies it to clipboard / close MSpaint / erases the file.

Hope this helps.

You can change the end to paste the clipbloard in MS Powerpoint, Word or excel ...