Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a macro used to select actual month and year in my application:
ActiveDocument.GetField("Month").Select ActiveDocument.Evaluate("date(addmonths(monthstart(today(1)),-1),'MM')")
It was working, till I defined my Month field properties to integer.
Can anyone help me fixing this function?
I'm guessing this should work:
ActiveDocument.GetField("Month").Select ActiveDocument.Evaluate("date(addmonths(monthstart(today(1)),-1),'M')")
I did a quick test and 05 is different from 5. If I use your original expression, I can select months stored as 05. If I remove one of the Ms, it won't select 05, but it will select 5. I'd check how you're early months look, I'm guessing they don't have the leading zero.
I'm guessing this should work:
ActiveDocument.GetField("Month").Select ActiveDocument.Evaluate("date(addmonths(monthstart(today(1)),-1),'M')")
I did a quick test and 05 is different from 5. If I use your original expression, I can select months stored as 05. If I remove one of the Ms, it won't select 05, but it will select 5. I'd check how you're early months look, I'm guessing they don't have the leading zero.
It worked, but I am worried about last three years of the month: 10, 11, 12. Do You Think will it work?
Yes, those would have worked with either expression. One M means one number for the earlier months, but would still display as two numbers for October and later.
You could probably amend your expression to select a later month, by changing the parameter of the addmonths function to test it out. EDIT: I did addmonths(date, 5) for both MM and M and it selected 11.
Forget, I've found a way to test and it worked again. Thank You