Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all...
I recently received some assistance in creating a report which ran through a field list, filtered on same, and e-mailed a report.
In have found that I am missing one record....
For example I have four customers with the customer codes being stored in the field "cus_Code"...
The code I am using is as follows...
'===========================================================================
sub SubmitReportAll
Dim Msg, Style, Title, Response
Msg = "This routine sends an individual e-mail for each Customer to the recipient?"
Style = vbYesNo + vbExclamation + vbDefaultButton2
Title = "Are You Sure?"
Response = msgbox(Msg, Style, Title)
If Response = vbNo Then
Exit Sub
Else
End If
ActiveDocument.ClearAll true
Set val=ActiveDocument.Fields("cus_Code").GetPossibleValues(20000)
For i = 1 to Val.count - 1
ActiveDocument.Fields("cus_Code").Select val.item(i).Text
' set emailTo Variable
set ve = ActiveDocument.Variables("emailTo")
set vt = ActiveDocument.Fields("usr_EmailTo").GetPossibleValues
emailTo = vt.Item(0).text
ve.SetContent emailTo, true
' append Customer Code to end of emailSubject variable
set v = ActiveDocument.Variables("emailSubject")
set vname = ActiveDocument.Fields("cus_Code").GetPossibleValues
emailSubject = "QlikView ME06 Report - " + vname.Item(0).text
v.SetContent emailSubject, true
' Print Report
vo = ActiveDocument.Variables("emailOutput").GetContent.String
va = ActiveDocument.Variables("emailAttachment").GetContent.String
printReportPDF "RP01", vo, va
' Email Report
SendMail
Next
ActiveDocument.ClearAll true
end sub
'===========================================================================
On the face of it, this works okay but I am consitently only getting three e-mails - I should get 4.
Any help greatly appreciated...
Thanks
Paul
hi Paul,
debug it using a msgbox on i and see how your counter is moving
Mechanically it can only be the for statement causing this to happen, unless you have some bizarre behaviour due to data.
should the loop start at zero? why do you only go to Val.count -1. Have you tried moving one or the other?
For i = 1 to Val.count - 1
???
hi Paul,
debug it using a msgbox on i and see how your counter is moving
Mechanically it can only be the for statement causing this to happen, unless you have some bizarre behaviour due to data.
should the loop start at zero? why do you only go to Val.count -1. Have you tried moving one or the other?
For i = 1 to Val.count - 1
???
Thanks Pat
I had already tried removing the -1 aspect but kept getting errors after the 3rd e-mail had been sent.
Changed the loop start to a zero and this has done the trick (I always thought that this had to be a 1)...
Thanks for your help
Regards
Paul