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 export Pivot table to excel in the right format...

Hi,

I'm trying to export a pivot table to excel with the use of a macro, it works but like others on the forum the dimension ain't right... i want it to be like when you press the export to excel button on the table. It's the same problem here http://community.qlik.com/forums/t/23223.aspx

this is the macro is use:

sub export
set XLApp = CreateObject("Excel.Application")
XLApp.Visible = FALSE
set XLDoc = XLApp.Workbooks.Add

XLDoc.Sheets(1).name = "NBFTE lijst"
set XLSheet = XLDoc.Worksheets(1)
set MyTable = ActiveDocument.GetSheetObject("CH21")

set XLSheet = XLDoc.Worksheets(1) 'Select sheet where data should be pasted
XLSheet.Name="NBFTE lijst"
Mytable.CopyTableToClipboard true 'Copy data to Clipboard
XLSheet.Paste XLSheet.Range("A1")
XLSheet.Cells.EntireColumn.AutoFit
XLSheet.Cells.EntireRow.AutoFit

XLDoc.SaveAs "..\test.xlsx"

XLApp.Visible = False
XLApp.Quit
Set XLApp = Nothing
Set Table = Nothing

end sub

What to i need to add to have the right format??
Thx

1 Solution

Accepted Solutions
suniljain
Master
Master

set obj = ActiveDocument.GetSheetObject("CH703")
obj.ExportEx "E:\Qlikview\Prima\PPT\Department_Loadinng.xls",5

View solution in original post

3 Replies
pljsoftware
Creator III
Creator III

Hello!

Which version do you use? Since version 9 SR4 there is a bug that do not permit to export correctly a pivot table to excel.

suniljain
Master
Master

set obj = ActiveDocument.GetSheetObject("CH703")
obj.ExportEx "E:\Qlikview\Prima\PPT\Department_Loadinng.xls",5

Not applicable
Author

thx 🙂