Well, there are built-in QV functions to retrieve the current date and time:
Returns a timestamp of the current time from the system clock. The timer_mode may have the following values:
0 Time at script run
1 Time at function call
2 Time when the document was opened
Default timer_mode is 1. The timer_mode = 1 should be used with caution, since it polls the operating system every second and hence could slow down the system.
Returns the current date from the system clock. The timer_mode may have the following values:
0 Date at script run
1 Date at function call
2 Date when the document was opened
Default timer_mode is 2. The timer_mode = 1 should be used with caution, since it polls the operating system every second and hence could slow down the system.
So I am not sure why you want to use a macro for that, what do you want to do with the current date?
Use This Macro,
dim thisYear, thisMonth, thisDay, datestamp
set v = ActiveDocument.Variables("vMaxDay")
set vToday = v.GetContent
set v2 = ActiveDocument.Variables("vMaxMonth")
set vMonth = v2.GetContent
thisYear = year(vToday.String)
thisMonth = vMonth.String
thisDay = day(vToday.String)
I think you don't need a macro for that, you can do all this with a selection - select in field action, see also attached.
But anyway, if you want to run the selection or macro action on opening of the document, just create an appropriate trigger in
document settings - triggers (see also attached).
TodayButton_SW.qvw 145.8 K