Wednesday, November 24, 2010

Thinking of templates

Gerard: What are you doing, Newman?
Newman: Thinking.
Gerard: Well, think me up a cup of coffee.
(from The Fugitive,  starring Harrison Ford and Tommy Lee Jones).

The Occupational Psychologist has upgraded a few of her office computers to Windows 7 and Office 2010, whereas I work with Windows XP and Office 2003. All of the programs which I have written for her work without change ... as long as they don't try to open Word and display data there. As it happens, most of them do have to open Word, which means that we have a serious problem.

I thought that maybe the automation interface had changed, but that seems not to be the case. I looked around on the internet for solutions; one suggested putting in a 'sleep' statement after the call to open Word, another suggested changing protections. Neither solution worked. Suddenly, out of the blue, a word popped into my head - templates. My programs are written to open Word using a certain template and Word 2010 doesn't know where to find that template.

I quickly wrote a small test program which opens a document and types a few words without specifying a template. After transferring the program to the OP's office, we ran the program successfully. In other words, my hypothesis about the non-functioning Word link was correct: Word doesn't know where to find the correct template.

Of course, knowing the solution to the problem doesn't always help in implementing that solution. I've sort of found the correct place in Word to define the templates, but the dialog box has changed from Office 2003, but aside from that, the text appears in small Hebrew letters which are hard to read, and often Microsoft speaks a special dialect of Hebrew which most people can't understand.

So: if anyone reading this is versed in using Word 2010 automation with templates, please let me know.

Update:
It's just as well that I wrote this blog in advance of publishing it. Via the help of the wonderful stack overflow site, I found the place where I can define the default location of templates in Word 2010. If anyone's interested, it's Files|Options|Advanced|File locations. The button which activates the file locations dialog is located at the bottom of a very long dialog box and is almost hidden away. No wonder I didn't find it before (especially as I was looking in the wrong place). Methinks Microsoft is trying to tell us something.

No comments: