VBA Referencing

M

Mark

reI have a template which I keep a lot of code in which is referenced to by
quite a number of other templates. I want to move the template which is
referenced to another location on my computer, this will obviously affect the
reference link. it is possible with code to alter all my templates so that I
don't have to open them myself one by one and change the reference path?

If so, would someone by kind enough to assist me with some code, please?

Thanks
 
J

Jonathan West

Mark said:
reI have a template which I keep a lot of code in which is referenced to
by
quite a number of other templates. I want to move the template which is
referenced to another location on my computer, this will obviously affect
the
reference link. it is possible with code to alter all my templates so
that I
don't have to open them myself one by one and change the reference path?

If so, would someone by kind enough to assist me with some code, please?


The relevant item is the References collection of the VBProject object. You
need to identify the correct item in that collection. Then you need to
Remove that item, and then use the AddFromFile method to add a new reference
to the collection.

You will need to cycle through each of your templates in order to do that.
Work out the exact code necessary to do that once, and then put the relevant
code into the middle of the code sample in this article

Find & ReplaceAll on a batch of documents in the same folder
http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
Top