Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hiya Guys,
This is a good one!
I am trying to evaluate if the Month selected is equal to the current month (7) + 2 (September). In a macro I am (essentially) using the VBScript:
If (ActiveDocument.Evaluate("GetFieldSelections(MonthNumber,',',12)") = (Month(Now())+2)) then ...
My "IF" expression always returns "False". However, if I use the same expression for a Text Object (ie: =(GetFieldSelections(DateCourse_MonthNumber,',',12) = (Month(Now()))+2)) then selecting Month 9 (September) will display "-1" (True).
If anyone has any ideas please let me know - as, I am fairly sure, that "9" does in fact equal "9"... 🙂
Cheers,
Steve.
I solved this myself (but will post as it may help others in the future).
I was able to get the correct result by "adding zero" to my "GetFieldSelections" result... meaning that 9+0 = 9!!! 🙂
This must have been a casting issue - although I could not get Num() or Text() to work correctly.
Does anyone know of a better way? I was saving ther result of "GetFieldSelections" into a variable within my macro - so perhaps using the "Dual" function may have helped?
Cheers,
Steve.
I think IF expressiion should be
If (ActiveDocument.Evaluate("GetFieldSelections(MonthNumber,',',12)) = (Month(Now())+2)")
I solved this myself (but will post as it may help others in the future).
I was able to get the correct result by "adding zero" to my "GetFieldSelections" result... meaning that 9+0 = 9!!! 🙂
This must have been a casting issue - although I could not get Num() or Text() to work correctly.
Does anyone know of a better way? I was saving ther result of "GetFieldSelections" into a variable within my macro - so perhaps using the "Dual" function may have helped?
Cheers,
Steve.
You can use CInt() to convert to integer.