Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Export object to excel /text file macro trigger on a field selection?

Hi,

     Any one know how to write a macro to export the object to excel or text file for Field trigger?I want to keep on exporting the data to same excel/text file created for any selection.I don't want to replace the file whenever different values in the field are selected.

4 Replies
Not applicable
Author

Hi,

This is the macro:

sub CopyToXL2

set XLApp = CreateObject("Excel.Application")

XLApp.Visible = FALSE

set XLDoc = XLApp.Workbooks.Add

XLDoc.Sheets(1).name = "Supervisor Report"

set XLSheet = XLDoc.Worksheets(1)

set MyTable = ActiveDocument.GetSheetObject("CH02")

set XLSheet = XLDoc.Worksheets(1)

MyTable.CopyTableToClipboard true

XLSheet.Paste XLSheet.Range("A1")

XLDoc.SaveAs "C:\Users\igal\Documents\BU\MyRep.xlsx"    'Choose the file path you like

XLApp.Visible = False

XLApp.Quit

Set XLApp = Nothing

Set Table = Nothing

end sub

End then go to->Settings->Document Properties->Triggers->Field Event Trigger

See the attached.

Hope it help.

Not applicable
Author

Thank you very much Yigal for quick response.I am not a macro person.The macro works good.But it is every time asking me whether to replace the old excel file or not? I want to add the data to the existing excel if  another selection is made.And it also generates two sheets.One the object i needed and the other the selection table.I want only the object.Actually I am making a selection in one object and trying to export the data from another object based on the selection.I have read some where in community little bit similar to my question

http://community.qlik.com/message/200603

Can we use AppendExport also to do similar thing with the data exported to the same excel sheet whenever the field selected?

Not applicable
Author

Hi Yigal I have attached your application with notes about how I want to do the export.

Not applicable
Author

Hi,

If you want to export data to excel, the folowing article could be useful for you:

http://www.codeproject.com/KB/cs/Excel_PDF_Word_ExportWiz.aspx?msg=3768323#xx3768323xx