Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I wrote a macro (VBS) to print a report to PDF and then mail it.
I need to loop through a field to generate a PDF report for each value and then get the email address associated (ie, the possible selection on the email field).
The code I wrote doesn't work as sometimes the current selections change when I try to get the possible values for the second field!
Can anyone point me in the right direction? thanks!
The same problem is already described in this post of 2010 (not answered)
Loop through multiple listBox selections and export to Excel
I'm sending a piece of the code I wrote below.
(...)
for i = 0 to mySelections.Count - 1
Dim FieldValue FieldValue = mySelections.Item(i).text ActiveDocument.Fields(FieldName).Select FieldValue
Print_PDF FieldValue, reportName, in_ReportID, reportPath
' here is the line where the field selection changes set thisEmailSelection = ActiveDocument.Fields(EmailFieldName).GetPossibleValues(1)
If thisEmailSelection.Count = 1 Then
Next set mySelections = Nothing
end sub |
Regards,
Marina Carvalho