Using Field.add on header/footer section

J

Jeffery B Paarsa

Hello all,

On the Header/Footer section of a few Word Templates I have a drawing line
and a FIELD CODE that will be updated each time a new document will be
created by the code that is show bellow. Inside of the Header & Footer
section FIELD CODE, I have an INSERTTEXT "C:\\xxdir\\copiedfrom.doc" FootAdd
\*charformat. Everything works perfect and I have no problem with my code.

I would like to remove this dependency of "C:\\xxdirâ€. I am using Set
ProgNote = Word.Documents.Add(Template:=Application.MacroContainer.Path +
“Temp.dot†command to access and invoke my templates. How can I use
Field.Add or any other way on these Header/Footer sections to remove this
dependency of drive/directory name so my templates would become totally
independent of the drive/directory names?

I traced the code and I noticed that that I go thru several loops for each
Header/Footer section. If I use FIELD.ADD how can I provent not to
cluber/destroy or delete my drawing lines at the time of Field.add?

Dim oField As Field
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Update
Next oField
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
oField.Update
Next oField
End If
Next oFooter
Next oSection

Thanks for you help.
 
D

Dave Lett

Hi Jeffrey,

Is the range of FootAdd just text (i.e., no graphics)?
Is the text formatted in any way?

Dave
 
J

Jeffery B Paarsa

Hi Dave,

Yes it is plain text with no picture or graphic showing the business
location address and the web site for the business that I prefer the color of
the web site address to be blue and the font a little bigger than the font
for the business address location.
 
J

Jeffery B Paarsa

Hi Dave,

Yes it is plain text with no picture or graphic showing the business
location address and the web site for the business that I prefer the color of
the web site address to be blue and the font a little bigger than the font
for the business address location.
 
D

Dave Lett

Hi Jeffery,

Instead of inserting the text of a document, you could place the text in an
AutoText entry and insert that material. You could alternatively save the
text as a custom document property or a document variable in the template
and then insert the material from there.

HTH,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top