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.
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.