There are three tables with the same Date field ([Actual ship date]). To have a correct separate calendar table with unique dates from all three tables I'm concatenating distinct date field from all tables in to one, and then got distinct values from that table. In new table such fields as Year, Quarter, Month, Week are created. Common thing in many analytics.
There is a need to have current Quarter Weeks selected on document open (e.g. now, first four weeks will be selected). I have special variable for maximal sales date (format DD.MM.YYYY). I can't use formula Max([Actual ship date]) in objects, 'cause there are budget data with dates in the future. I wrote the simple macro and associated it with document open action:
'------------------------------------------ ' On Document Open sub DocumentOpen ' 1. Selects Current Quarter ActiveDocument.ClearAll True set d=ActiveDocument.Fields("Actual ship date") d.Select ActiveDocument.Evaluate("'$(MaxSalesDate)'") ActiveDocument.Fields("Quarter").SelectPossible ActiveDocument.Fields("Year").SelectPossible
' 2. Selects Actual weeks for correct Budget d.Select "<="& ActiveDocument.Evaluate("'$(MaxSalesDate)'") ActiveDocument.Fields("Week").SelectPossible d.Clear end sub
To avoid problems with date formats I used ActiveDocument.Evaluate feature
Now the issue - the script goes perfectly till the end and then I've got global script error:
In log file also everything is finished normally, synthetic keys are created and words "Execution finished." are in the last row.
The error is using QV 9.00.7320.7 SR2 64-bit edition. In 8.50.6299.5 64-bit version everything is fine.
Removing trigger for Document opening for the first time makes reload normally in 9.00 version. But after another try to add trigger the same strange error appears. After that no manipulation reanimates reload in 9.00. And still in 8.50 everything is fine. I have a feeling, that document is corrupted with that macro. But while opening document in 9.00 macros works correct.
Many solutions have been tried by me (reinstalling of QV, creating of new document step-by-step, manipulating with reloads in different versions). Nothing!
The weirdest thing is that I have the same script part and macros in other document and no problems with that.
May be somebody could suggest one more version of macros?