Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I understand that fields can be selected via macros using something like:
ActiveDocument.Fields("Year").Select '.....'
But what if I need to select an item or a number of items in a listbox which is based on an expression rather than a field? Or alternatively select a cell or range of cells in a table object?
I am experimenting with code similar to the following:
Set oLB_Cat = ActiveDocument.GetSheetObject("CAT")
Set oCell = oLB_Cat.GetCell(1,0)
oCell.State = 1
But it does not seem to have any effect. Is this the right approach or is there another method?
Following should work in your macro. It will look for range of valeus between two values and select it for the field
'''set variable with values
set vVarStart=ActiveDocument.Variables("vStart")
set vVarEnd=ActiveDocument.Variables("vEnd")
''get you expression in the variable.
vStartSearch= vVarStar.GetContent.String
vEndSearch=vVarEnd.GetContent.String
'''Search values of your variable
vSearch = "=IF( [YourField] >= '" & vStartSearch & "' AND [YourField] <= '" & vEndSearch & "',True(),False())"
ActiveDocument.Fields("YourField").Select vSearch