You are visitor number since 22 July 2004. Go to Howard Kaikow's home page
Copyright © 2004 by Howard Kaikow. All rights reserved.
Date: 22 July 2004
From: Howard Kaikow <email@example.com>
Subject: Cannot add reference to Word template project via Automation
It does not seem possible to add a reference to a Word template project using Automation. This seems like a rather serious bug.
The problem does not exist with Word 97, but exists for Word 2000, Word 2002 and Word 2003.
Without using Automation, I can delete a reference, then recreate the reference in a Word template, and the resulting reference does get saved with the changed template.
However, the reference does not get saved if I use Automation with a Word object in any of the following:
Note that the reference does get added, one can see this by stepping thru the code, and examining the physical file. However, the reference does not get saved with the template when the code ends, implying that Word is somehow working with a temporary copy of the template and not correctly updating the saved template.
I tried an analogous problem using Excel and no such problem exists when adding a reference to an Excel Workbook
I am providing a Microsoft Word template that can be used to reproduce the problem.. I created the template using Word 97. The template can be used in Word 97, Word 2000, Word 2002 and Word 2003.
You may need to change the values assigned to the strDLLPath, strReference and strTargetPath variables.
Sub SetReferenceInWordNotUsingWordObject will produce the expected result, i.e., the reference will be saved.
Sub SetReferenceInWordUsingWordObject will NOT produce the expected result, i.e., the reference will not be saved.