Calendar Template - Word Mac 2011

Hi

Trying to make a Calendar for January 2015, I select the template, I select the dates and whatever I do the year is selected to 2014, regardless of the template or the year I select, it always goes back to 2014.  

Tried going back to the menu toolbar and selecting "Calendar > Select Dates", also tried using the path Shift+Option+return

Its driving me mad, what am I doing wrong?

thanks for any help

Answer
Answer

{Chortle}  Well, THAT was a six-hour hunt through the minutiae of the templates.

Conrad, it turns out that you are quite correct, there is an extremely obscure bug. I can't say for sure whether it is in Yosemite or Word, but it ain't right!

Daniel Grau has now confirmed that the problem occurs if the Apple System Preferences Locale is set to anything other than "United States".  Peter Jamieson has further confirmed that Yosemite has changed the way it encodes the "Short Date".  Read his answer on the next page of this thread.

Just for those listening at home, the dates (Year, months, days) in the Word templates are all filled in from a VBA form that appears when you open a template, or when you fire the Calendar>Select Calendar Dates macro.

That puts up a form in which you select a month and year.  The VBA in the Form code then turns your selections into a computer date that it can calculate with.

The business end of the code is here:

Set Vars = ActiveDocument.Variables
iYear = frmSelectMonthAndYear.cboSelectCalendarYear
iMonth = frmSelectMonthAndYear.cboSelectCalendarMonth

'Get the first day of the month
 dStartDate = DateSerial(iYear, iMonth, 1)

'Update DocVariables with first day of month and last day of month
 Vars("MonthStart").Value = dStartDate
 Vars("MonthEnd").Value = DateAdd("m", 1, dStartDate) - 1

That retrieves the year and month you have chosen in the pop-up, turns it into a digital date (dStartDate) then writes the value into two document variables, MonthStart and MonthEnd, calculating the last day of the month while it is doing that.

Later, in the template's text, the date is displayed twice, once in the name of the month, and once in the year.  If you right-click the month name in any of the templates and choose Toggle Field Codes, you will see {  DOCVARIABLE  MonthStart \@ MMMM \* MERGEFORMAT } in the Month name, and { DOCVARIABLE  MonthStart \@  yyyy   \* MERGEFORMAT } in the Year.  These DOCVARIABLE fields are simply retrieving the value that was written into the document variable "MonthStart" in the code above, and displaying it as either a month name or a year integer.  This code is expecting to find a "Serial Date" in the document variable, which for Monday, December 22, 2014 should be an integer: '41995'.


And on other operating systems, it is, and the code "just works".  In Word 2011 on Yosemite, the field is being stored as '#1/01/#'.  There's a couple of problems there: the first is that it is not a serial date, it's a text string encoded as a date.  The # symbols tell the code "store this as an 8-byte serial date".

Word's code is quite forgiving: it would work this out and display it correctly except for the other problem: the YEAR is MISSING!  And when the year is missing, Word and VBA rules say "assume the current year!"

Now I can't go burrowing into the internals of Mac OS X to tell you whose fault this is, and I do not know what function VBA in Microsoft Office calls to read/write dates.  But the fact that it works in versions of Mac OS X prior to 10.10 indicates the change was on the Apple side.

OK, to fix it, we need to change just the Year field.  Go to the template file itself (no point in fixing the document, you would have to do that every time).  You should find the calendar templates in

Macintosh HD ▸ Applications ▸ Microsoft Office 2011 ▸ Office ▸ Media ▸ Templates ▸ Print Layout View ▸ Calendars.

Right-click the Year, choose "Toggle field codes" and change it to { DOCVARIABLE  Year }













You don't need anything else there to decode the serial date, because we're going to add that variable to the template and store the year in it as an integer.
 Toggle the field codes back again, but don't update yet, the variable it is looking for doesn't exist yet.

You now need to go into the VBA code and make the corresponding change.


To get there, open your chosen template (they ALL need the same fix...) and go to the Tools Menu.  Choose "Macros" then choose the VBA Editor.  With luck, this will open in its standard view, with the Project pane open on the left.  Towards the bottom, look for "TemplateProject", and under that, "Forms" and within Forms, "frmSelectMonthAndYear"




Right-click that and choose View Code.  The code will open. You need to add one line:


Where it reads:


' Update DocVariables with first day of month and last day of month


 Vars("Year").Value = iYear

 Vars("MonthStart").Value = dStartDate


 Vars("MonthEnd").Value = DateAdd("m", 1, dStartDate) - 1


Add the line in bold: Vars("Year").Value = iYear

That simply writes the value you chose for the year into the document.


Now click the blue 'W' at the top left corner to come out of the editor.


Go to the Calendar menu and click Select Calendar Dates. 

Choose your month and year.  They will stick this time!


Note:  If you have saved any calendar files as documents, you will need to make the same changes in each of them (or simply create new ones from the template you have fixed.

Oh:  I guess I should answer some implied questions here:

1)  Will Microsoft fix this?  No.

2)  Will Apple fix this problem for you?  No.

3)  Will some other user fix the calendar templates for you? Yes, if you ask nicely in here -- you will, of course, need to provide some means of contacting you.  No, we are not going to phone you. :-)

Hope this helps 


John McGhie, Consultant Technical Writer.

2 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 3,223 Applies to: