Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

raghavsurya
Valued Contributor

macro to copy 2 charts to clipboard at once

Hi All,

We have a scenario wherein the user wants to copy more than 2 charts/tables and paste it to other application (MS Word, powerpoint etc).  Can anyone share with me a macro to do it.

Regards,

Raghav  

2 Replies
prieper
Honored Contributor II

macro to copy 2 charts to clipboard at once

Have taken the below macro from an earlier post, actually it is related for copying into Excel, but shows the principle:

SUB MultipleExport2XLS()

'***********************************************************************************

'        This macros copies multiple charts or tables into an Excel-File

'            Seems not to be possible to copy a textobject

'

'                                                kind courtesy of radoi (NG 20090124)

'***********************************************************************************

    iRow=1 'counts the rows or the colums - depends where you place it in the code

    

'    ======================================================== Open Excel

    SET xlApp = CreateObject("Excel.Application")

    xlApp.Visible = True

    'Set xlWB = xlApp.Workbooks.Open("C:\test.xls") 'opens existing workbook test.xls

    'Set xlSheet = xlWB.Worksheets("test") 'selects the worksheet we need

    SET xlWB = xlApp.Workbooks.Add

    SET xlSheet = xlWB.Worksheets(1)

   

    xlSheet.Activate 'the worksheet must be active in order to paste in it

    xlSheet.Cells.Clear 'clears entire content of the worksheet

'    =================================================== Copy First Object

    SET obj = ActiveDocument.GetSheetObject("CH01") 'first table

    obj.CopyTableToClipboard TRUE

    xlSheet.Cells(iRow,1).Select 'this is where we paste

    xlSheet.Paste

'    =================================================== Copy Second Object     

    WHILE NOT (IsEmpty(xlSheet.Cells(iRow,1))) 'looks for the first empty cell on the first column

        iRow = iRow + 1

    WEND

    

    SET obj = ActiveDocument.GetSheetObject("TB01") 'second table

    obj.CopyTableToClipboard TRUE

    xlSheet.Cells(iRow, 1).Select 'this is where we paste

    xlSheet.Paste

'    ====================================================== Close and Save           

    xlWB.Close True 'closes the workbook. "True" means that it saves modifications

    xlApp.Quit 'closes excel. it's quite important

END SUB

HTH
Peter

Not applicable

macro to copy 2 charts to clipboard at once

There is a really good qvw in the share qlikviews section on this.  I've used it extensively but it is a little complicated (it uses a function with an array or something.... clearly I dont' really know what I'm talking about) but it is pretty easy to use if you don't really want to edit anything.  I can't even find the share qlikviews section right now I can't really link it for you.... but I'll edit this if I find it.

Community Browser