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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pivot table - Macro Send to Excel does not create same spreadsheet as Icon Send to Excel

I created a pivot table showing year, customers, parts and the sales for each month (Jan, Feb, Mar....Dec)

     2013     ABC Co.    bolts     120     200    123     30     100 .......    

                                        nuts     120         0     300       0     103 .......

                   EFG Co.     bolts        3        10        7       0        10 ......

The table has all the customer and part groups expanded.  When I use the window icon, SEND TO EXCEL the information in the pivot table
goes to excel and each line of the spread sheet is populated (there are no colums with merged cells).  Just what I want.

     2013     ABC Co.    bolts     120     200    123     30     100 .......    

     2013     ABC Co.    nuts     120         0     300       0     103 .......

     2013    EFG Co.     bolts        3        10         7       0        10 ......


I have a Macro that creates the excel spreadsheet as well.  However, when I open the spreadsheet it mimics the original pivot table (the column data is grouped and shown only once).    

     2013     ABC Co.    bolts     120     200    123     30     100 .......      

                                        nuts     120         0     300       0     103 .......

                   EFG Co.     bolts        3        10         7       0        10 ......

Is there a VB script that works like the SEND TO EXCEL icon?

Here is the Macro Script I am using

 

'Create the Excel spreadsheet
Set excelFile = CreateObject("Excel.Application")
excelFile.Visible = true

'Create the WorkBook
Set curWorkBook = excelFile.WorkBooks.Add

'Create the Sheet
Set curSheet = curWorkBook.WorkSheets(1)

'Get the chart we want to export
Set tableToExport = ActiveDocument.GetSheetObject("CH128")

ActiveDocument.Fields("ext_cal_year").Select ExtractYear


Set chartProperties = tableToExport.GetProperties
tableToExport.CopyTableToClipboard true


curSheet.Paste curSheet.Range("A1")
excelFile.Visible = true

'Save the file and quit excel
curWorkBook.SaveAs filePath
curWorkBook.Close
excelFile.Quit

1 Solution

Accepted Solutions
whiteline
Master II
Master II

Hi.

set obj = ActiveDocument.GetSheetObject("CH128")

obj.ExportEx "C:\Filename.xls",5

View solution in original post

3 Replies
whiteline
Master II
Master II

Hi.

set obj = ActiveDocument.GetSheetObject("CH128")

obj.ExportEx "C:\Filename.xls",5

Not applicable
Author

Your solution worked great!

Thanks

Not applicable
Author

Your solution worked Great!

Thanks