Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I try in a macro to test the selected value of a field ; however,I don't find the right syntax.
The following example ends with an error :
Sub OneValue
Set ValsforField = ActiveDocument.Fields("Answ").GetSelectedValues
If ValsforField.value = "No" then
ActiveDocument.Fields("Answ").Select"Yes"
elseif ValsforField.value = "Yes" then
ActiveDocument.Fields("Answ").Select"No"
end if
end sub
Thank you for you help,
Best Regards,
Jaymerry
Hi Jaymerry,
.value is unknown and fit not correct then GetSelectedValues returns an array() - use instead .Item(0).Text
If ValsforField.Item(0).Text = "No" then
ActiveDocument.Fields("Answ").Select"Yes"
elseif ValsforField.Item(0).Text
= "Yes" then
ActiveDocument.Fields("Answ").Select"No"
end if
- Marcus
Hi Jaymerry,
.value is unknown and fit not correct then GetSelectedValues returns an array() - use instead .Item(0).Text
If ValsforField.Item(0).Text = "No" then
ActiveDocument.Fields("Answ").Select"Yes"
elseif ValsforField.Item(0).Text
= "Yes" then
ActiveDocument.Fields("Answ").Select"No"
end if
- Marcus
Thanks for your help, it works.
BR
Jaymerry