Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a table of settings for sending mails automatically
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 ?
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
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