Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?!?!?
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?
The looping and selecting.....
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
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
Is the text box necessary? i was trying to get it to automatically cycle thru the said "field" without having to click ok....
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.