Hi All
I am trying to select a YTD date range for the current year as well as the previous year.
Now i a trying to populate variables to keep this dynamic and not static.
Have a look at this:
Sub Select1
ActiveDocument.Fields("Year").ToggleSelect("2009")
ActiveDocument.Fields("Year").ToggleSelect("2010")
ActiveDocument.Fields("MonthNumber").ToggleSelect("01")
ActiveDocument.Fields("MonthNumber").ToggleSelect("02")
ActiveDocument.Fields("MonthNumber").ToggleSelect("03")
ActiveDocument.Fields("MonthNumber").ToggleSelect("04")
ActiveDocument.Fields("MonthNumber").ToggleSelect("05")
ActiveDocument.Fields("MonthNumber").ToggleSelect("06")
End Sub
This gives me a YTD selection on Both 2009 and 2010.
The problem is i need to Pass the value Ex. MonthNumber = 05 etc as a variable.
I have tried doing: ActiveDocument.Fields("MonthNumber").ToggleSelect("=$(vMonthNumber)")
but it doesn't seem to work. Then what would be the Ultimate is if you can put a For statement on top of all that so it would look
something like this:
Sub SelectYTD
For i = 1 to Num(Month(Today()))
ActiveDocument.Fields("MonthNumber").ToggleSelect("i")
next i
ActiveDocument.Fields("MonthNumber").ToggleSelect("=$(vCurrentYear)")
ActiveDocument.Fields("MonthNumber").ToggleSelect("=$(vPrevYear)")
End Sub
If anyone is able to help me or even assist me, Please do.
Please note, unfortyunitly my client is only running 8.5 so actions is not of any importance.
Thanks,