Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Need help combining multiple straight tables into one table to export into Excel? The columns are identical in all tables.
OR - use the send to excel function to send the data into the same excel sheet?
The data is in separate straight tables due to calculations being performed on the field values - separate calculations each table.
Any help is appreciated.
Thanks,
Here's a macro you can use to export multiple tables to the same Excel Worksheet. You should create a variable vNoTables that is 3 and change the object ID's of your tables to T1, T2 and T3.
sub CopyToXL
dim iCount
dim No_Tables
dim ObjName
dim ObjCaption
iCount=1
set XLApp = CreateObject("Excel.Application") ' Define Object
XLApp.Visible = True 'Visible set as true
set XLDoc = XLApp.Workbooks.Add 'Open new workbook
'Take the List of Object's in Excel
set XLSheet = XLDoc.Worksheets(1)
No_Tables = CInt(ActiveDocument.Variables("vNoTables").GetContent.String)
for i = 1 to No_Tables
set SheetObj = ActiveDocument.GetSheetObject("T" & i)
ObjCaption = SheetObj.GetCaption.Name.v
SheetObj.CopyTableToClipboard true
if i=1 then
XLSheet.Range("A"&iCount) = ObjCaption
XLSheet.Range("A"&iCount).Font.Bold = True
XLSheet.Paste XLSheet.Range("A"&iCount+1)
else
XLSheet.Paste XLSheet.Range("A"&iCount)
end if
iCount= XLSheet.UsedRange.Rows.Count + 1
next
end sub
wow - writing a macro in Qlikview is over my head. I'll do some research on how that's done, and give this a try.
Thanks.
Hi,
have a look at http://www.qlikblog.at/971/qliktip-32-exporting-multiple-objects-single-excel-document/
This article can maybe help ...
Regards, Stefan
Any idea how the same code be applied to export multiple tables held in a container? I'm unsure how to activate a sheet object in a container.
Below is the same general code althought modified with a Do loop.
'Here's a macro you can use to export multiple tables to the same Excel Worksheet. You should change the object ID's of your tables to T1, T2 and T3.
sub CopyToXL
dim iCount
dim No_Tables
dim ObjName
dim ObjCaption
iCount=1
set XLApp = CreateObject("Excel.Application") ' Define Object
XLApp.Visible = True 'Visible set as true
set XLDoc = XLApp.Workbooks.Add 'Open new workbook
set XLSheet = XLDoc.Worksheets(1)
No_Tables = 3
DO WHILE No_Tables < 4
Set SheetObj = ActiveDocument.GetSheetObject("T"&No_Tables)
SheetObj.CopyTableToClipboard true
XLSheet.Paste XLSheet.Range("A"&iCount)
iCount= XLSheet.UsedRange.Rows.Count + 2
No_Tables = No_Tables + 1
LOOP
end sub