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

filter with macro before export to excel

Hello everyone,

thank you very much for the support so far here. You are great.

I have so far managed using a macro to export a table. However, these data should be filtered before export it, best also via Macro. Does anyone know of a way? The approaches presented here have not yet brought me to the destination.

Thank you for your help.

Kind regards,

Chris

My previous macro:

Sub exportToExcel

  set obj = ActiveDocument.GetSheetObject("CH695_903948695")

  obj.ExportEx "E:\SASCHA_Export\test.xls", 5

  msgbox("Export successfully completed.")

end sub

4 Replies
Gysbert_Wassenaar

Use a Select in Field action to make the selection and add that action to the same object you added the Run Macro action. Make sure the Select in Field action is placed above the Run Macro action so that the selection is made before the macro is executed.


talk is cheap, supply exceeds demand
Not applicable
Author

Yes u're right. I already tried this. But unfortunately it doesn't work.

See here my code:

Sub exportToExcel

  ActiveDocument.Fields("# GPartner").Select "=2"

  set obj = ActiveDocument.GetSheetObject("CH695_903948695")

  obj.ExportEx "E:\SASCHA_Export\test.xls", 5

  msgbox("Export successfully completed.")

end sub

I got following errormessage => Object required: 'ActiveDocument.Fields(...)'

"# GPartner" is the description from the exporting table.

Kind regards,

Chris

omyahamburg
Creator II
Creator II

You need to delete the equal sign:

ActiveDocument.Fields("# GPartner").Select "2"

Not applicable
Author

Nothing happens except the error already described.

Also tried another column without the "#" and another value.