Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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
MVP & Luminary
MVP & Luminary

Re: filter with macro before export to excel

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

Re: filter with macro before export to excel

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
Contributor II

Re: filter with macro before export to excel

You need to delete the equal sign:

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

Not applicable

Re: filter with macro before export to excel

Nothing happens except the error already described.

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

Community Browser