Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everybody,
I have the following code executed in a macro button:
Sub SelectUA
set s = ActiveDocument.Fields("UA").GetPossibleValues
for i=0 to s.Count-1
m = s.Item(i).Text
ActiveDocument.Fields("UA").Select m
ActiveDocument.GetApplication.Refresh
ActiveDocument.GetApplication.WaitForIdle
tp = ActiveDocument.GetApplication.MsgBox (m,1)
if tp = 1 then
exit for
end if
next
ActiveDocument.Fields("UA").Clear
end sub
the problem is that the MsgBox function allways return a 0 (OK or CANCEL pressed) so the Sub executes until the end of the for loop.
How can I solve this problem ?
Regards,
Thank you.
I usually use the VB Script MsgBox. Try this in place of your MsgBox line:
tp = MsgBox(m, 1)
That should give you a message box with m as the prompt and OK & Cancel buttons. Cancel should return a 2, Ok a 1.