Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

custom export excel

I have a table of settings for sending mails automatically

qv.png

I use this script

set field1Values = ActiveDocument.Fields("Nom").GetPossibleValues

set field2Values = ActiveDocument.Fields("Adresse MAIL").GetPossibleValues

set field3Values = ActiveDocument.Fields("Flag").GetPossibleValues

SET Field = Doc.Fields(FieldName).GetPossibleValues

FOR i=0 to Field.Count-1

for L = 0 to field1Values.Count - 1

    for j = 0 to field2Values.Count - 1

        for k = 0 to field3Values.Count - 1

         ActiveDocument.ClearAll()

         ActiveDocument.Fields("Nom").Select field1Values.Item(L).Text

         ActiveDocument.Fields("Adresse MAIL").Select field1Values.Item(j).Text

         ActiveDocument.Fields("Flag").Select field1Values.Item(k).Text

Doc.FIelds(FieldName).SELECT Field.Item(i).Text

Doc.GetApplication.WaitForIdle

  Doc.GetSheetObject("CH461").CopyTableToClipBoard TRUE

  xlApp.ActiveSheet.Paste

  xlApp.Worksheets(xlApp.ActiveSheet.Index).Cells.EntireColumn.AutoFit

  xlApp.Worksheets(xlApp.ActiveSheet.Index).Cells.EntireRow.AutoFit

xlApp.DisplayAlerts = FALSE

xlBook.SaveAs XLSFile, 56

xlBook.Close

XLSFile = ""

NEXT

    next

    next

next

 

This script returns wrong results , it exports files for each code site and for multiply flag , name, and ADDRESSE MAIL , not the ones is related to them , hox to correct it ?

1 Solution

Accepted Solutions
marcus_sommer

I think the reason is that you run through various fields whose values are not related to eachother like in a table - it are just distinct values of these field. To resolve this create a (or maybe several) tablebox(es) and run a loop through them, see: Re: vb scrip to display name

- Marcus

View solution in original post

1 Reply
marcus_sommer

I think the reason is that you run through various fields whose values are not related to eachother like in a table - it are just distinct values of these field. To resolve this create a (or maybe several) tablebox(es) and run a loop through them, see: Re: vb scrip to display name

- Marcus