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: 
james
Creator III
Creator III

Email and looping thru Macro

All, I have spent hours seeking and have found many different solutions. But not one excatly answers the question, loop on a field, i.e sales rep, and than email each answer a jpeg of the chart filtered... All while keeping the dates selected

Any help?!?!?

6 Replies
Not applicable

What exactly is not working for you, is it the looping and selecting or attaching an chart export image to an email, or something else?

james
Creator III
Creator III
Author

The looping and selecting.....

yblake
Partner - Creator II
Partner - Creator II

You may have to keep in memory selected values prior to select them one by one,

else loop to all possible values.

This will help you :

set ad = ActiveDocument
set fd = ad.Fields('MyField')

' use GetSelectedValues to loop only in currently selected values
set pv = fd.GetPossibleValues(5000)

if pv.Count > 0 then

for i = 0 to pv.Count-1

' Select value
set fv = fd.GetNoValues
fv.Add
fv(0).IsNumeric = pv.Item(i).IsNumeric
if fv(0).IsNumeric then
fv(0).Number = pv.Item(i).Number
else
fv(0).Text = pv.Item(i).Text
end if
fd.SelectValues fv
set fv = nothing

' Selected ?
if (fd.GetSelectedValues(5000).Count = 1) then

' Do some stuff here
' call email(fd)

end if

' Deselect
set fv = fd.GetSelectedValues(5000)
fv.RemoveAt 0
fd.SelectValues fv
set fv = nothing

next

end if

set pv = nothing
set fd = nothing
set ad = nothing

Anonymous
Not applicable

Here is a simple example of looping and selecting


sub Looping
set R = ActiveDocument.Fields("Rep")
set C=R.GetPossibleValues
for i=0 to C.Count-1
call Selecting(C.item(i).text)
next
end sub
function Selecting(F)
set R = ActiveDocument.Fields("Rep")
R.Select F
msgbox(R.GetSelectedValues.item(0).text)
' or whatever you want here
'....
R.Clear
end function


james
Creator III
Creator III
Author

Is the text box necessary? i was trying to get it to automatically cycle thru the said "field" without having to click ok....

Anonymous
Not applicable

You mean the message box? It's not necessary. I put it here only to be able to see what happens on each cycle. You can put whatever you need there.