Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
When we apply macro to select say say two products A and B.
In the current selection it comes as (A|B). but i want it as A,B just like normal selection .
Also if i have a value like age . I apply macro for selection in age as (""2 years""|""4 years"")
It comes in current selections as ("2 years"|"4 years"). Is there a way to replace this bar in macro script by , and ger rid of these brackets, inverted comas etc?
Thanks
Khushboo
If you do a more elaborate VBScript coding you can get your comma:
Sub SelectMyValues
Set f = ActiveDocument.Fields("Year")
Set fv = f.GetNoValues 'empty array
fv.Add
fv.Add
fv(0).Number = 2015
fv(0).IsNumeric = true
fv(1).Number = 2010
fv(1).IsNumeric = true
If Not( f.SelectValues(fv) ) Then
' do some error handling
End If
End Sub
If you do a more elaborate VBScript coding you can get your comma:
Sub SelectMyValues
Set f = ActiveDocument.Fields("Year")
Set fv = f.GetNoValues 'empty array
fv.Add
fv.Add
fv(0).Number = 2015
fv(0).IsNumeric = true
fv(1).Number = 2010
fv(1).IsNumeric = true
If Not( f.SelectValues(fv) ) Then
' do some error handling
End If
End Sub
if i have to test for string rather than numberic values?
Can you modify macro for string ?
You change
fv(0).Number = 2015 into fv(0).Text = "2015"
and
fv(0).IsNumeric = false
Thanks Petter 🙂
Petter,
If we have more than 2 values to select .
fv(2).Number = 2011
fv(3).Number = 2012
Like this?