Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm sure this question must have been asked before but I cant seem to find an answer. I would like to create a macro that selects all values in a field that are less than the value in an input box. I have created an input box for the user to enter the final day in period and this value then feeds in to a caculated dimension so that the user can see invoice aging as of a specific point in time. I would like to be able to add a macro button that can also select only dates that are less than the value entered in the input box. I have seen many macros where a single value can be selected and a few more that show how to toggle values inside a for next loop but I havent seen anyone using a less than or more than statement in a macro. Is it possible?
Thanks in advance.
The syntax in a macro is similar to what you would use in an Action.
Sub Selector
inputVal = ActiveDocument.Variables("vVar").GetContent.String
ActiveDocument.Fields("FIELD").Select "<" & inputVal
End Sub
For an Input Box with vVar as the variable.
You should be able to accomplish this by using actions instead oi macro's. Create a button and add a "selection->select in field" action . This allows you to use the advanced search syntax, where you can use ">" or "<" operators.
Lucas
The syntax in a macro is similar to what you would use in an Action.
Sub Selector
inputVal = ActiveDocument.Variables("vVar").GetContent.String
ActiveDocument.Fields("FIELD").Select "<" & inputVal
End Sub
For an Input Box with vVar as the variable.
As simple as that! Thanks NMillar
I couldnt find how to add the action to a button, Lucas. Is this new in v9? We are still at 8.5 at the moment.
Yes, you are correct Actions where added to v9.
Lucas
what if the field content is not a number, is string,
I.E this can ve a sample of the values:
FIELDnamex
R2968
R2968, R3266, R2344, R35425, R2337, R3553
R3023, R3203
R3084, D19516, D19349, D19442, D19430, D18967, D19523
R3098
R3179
R3221
and you want to search values with 2337 and 3098 or 2968
How the macro will look?
Thanks
First, you need to get your search criteria into a variable. If vTest = 2337, then you can use:
Sub Test
val = ActiveDocument.Variables("vTest").GetContent.String
ActiveDocument.Fields("FIELDNAME").Select "*" & val & "*", true
End Sub
Using wildcards on both sides of the value will look for the search criteria contained anywhere in the value.