Update Unbroken Reference

User avatar
arroway
3StarLounger
Posts: 368
Joined: 04 Jan 2012, 22:43

Update Unbroken Reference

Post by arroway »

What a pickle. It seems that I've backed myself into a corner. Does anyone know a way of updating a reference in a Word doc?

I have a locked, Word, template-form with installed macros on a company server. People have used this template, created instances of the form, filled them out, and saved them in a folder. They also have links to this file from different locations which I'm trying to maintain. When it came time to update the form, I updated the form and the Macros but kept the location and filename the same so the links that folks on my network have to this form wouldn't break. But now, when any of the forms which were created by the old form are opened, they are referencing a file with--follow me here--right filename, wrong file, wrong macro and they don't "work". I've renamed and saved the old version of the template in a different location and what I'm looking for is a way of updating the references in the files created by the old template to point to the old form with it's new name and in it's new location, thereby 'fixing' the reference and macros.

I've seen VBA code to help identify missing references and remove them but since the referenced file (while updated and wrong) still exists, it doesn't identify any missing references. I've also found VBA code to help replace broken or missing references but again, since the reference is not broken or missing, this code will not 'overwrite' or 'update' the reference. How can I overwrite this?

Thank you,
-Dax
It takes 2 to tango; unless you speak binary; then it takes 10.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Update Unbroken Reference

Post by HansV »

Do you really mean a reference as set in Tools > References... in the Visual Basic Editor? Or do you mean the template that the documents are attached to?
Best wishes,
Hans

User avatar
arroway
3StarLounger
Posts: 368
Joined: 04 Jan 2012, 22:43

Re: Update Unbroken Reference

Post by arroway »

I mean the template the documents are attached to. In the Vsiaul Basic Editor Project Viewer Windown (I think that's what it's called -- the window to the left) it shows:

Project (FILENAMEITWASSAVEDIN)
--Micosoft Word Objects
--References
----Reference to WORDFORM.DOT
TemplateProject (WORDFORM.DOT)
--Modules
----UPDATED MACRO NAME

I'm trying to change the above reference to "Reference to OLD VERSION WORDFORM.DOT"

If that makes sense. Does it? I might not be using the right words.
It takes 2 to tango; unless you speak binary; then it takes 10.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Update Unbroken Reference

Post by HansV »

You can change the template using code such as

ActiveDocument.AttachedTemplate = "\\myserver\myshare\myfolder\mytemplate.dotx"

or

ActiveDocument.AttachedTemplate = "S:\myfolder\mytemplate.dotx"

where S is the drive letter assigned to a shared network location.
Best wishes,
Hans

User avatar
arroway
3StarLounger
Posts: 368
Joined: 04 Jan 2012, 22:43

Re: Update Unbroken Reference

Post by arroway »

ROFL! You give me way too much credit Hans! :-) I don't know what to do with that. I tried opening one of the old files and adding that code to the Immediate window and hitting Enter but it throws an error and says Word cannot attach a document to a protected template. But when I OK-out of the msg I see that there's now the Project (File) and 2 TemplateProjects (one is the new one and one is the old one) but the 'Reference to' in the Project () part still lists the former reference and is not updated to the newly named old file.

I know I'm doing this totally wrong! Does that make any sense? A little help?
It takes 2 to tango; unless you speak binary; then it takes 10.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Update Unbroken Reference

Post by HansV »

I'm afraid I have no idea. Could you attach a copy of (a) a document and (b) the template?
Best wishes,
Hans

User avatar
arroway
3StarLounger
Posts: 368
Joined: 04 Jan 2012, 22:43

Re: Update Unbroken Reference

Post by arroway »

I can't publically. I can privately. Can you email me at dax@awablue.com and I'll send them over? I promise I'll only use your email for this issue.
It takes 2 to tango; unless you speak binary; then it takes 10.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Update Unbroken Reference

Post by HansV »

Before I do that, can you attach the correct template manually (interactively)?
- Open the document.
- On the Developer tab of the ribbon, in the Templates group, click Document Template.
- Click the Attach... button next to the Document template box.
- Locate and select the correct template, then click Open.
- Click OK.
Best wishes,
Hans

User avatar
arroway
3StarLounger
Posts: 368
Joined: 04 Jan 2012, 22:43

Re: Update Unbroken Reference

Post by arroway »

OH! That's the one!!! YES!! That's how it gets done. Thank YOU!!! :bananas: :bananas: :bananas: :bananas:
It takes 2 to tango; unless you speak binary; then it takes 10.