How to change the "includeText" field value in the Footer via VB/VBA

K

kartechy

Hi,

Im trying to change the "IncludeText" values in a word document
throguh VB (VBA) , I need to change lot of word documents (nearly
500) , I could change the values of the "includtext" fields in the
document body using the following


' /// after opened the document
lcode = WordDoc.Fields(i).Code
If Left(lcode, 12) = " INCLUDETEXT" Then
newCode = Replace(lcode, "V:\\", "C:\\")
WordDoc.Fields(i).Code.Text = newCode
WordDoc.Fields(i).Update
End If
' // save and close document and word objects

but this code is not changing the "includetext" in the
footer..


I dont know how to proceed now..can anyone help me here


Thanks
 
J

Jean-Guy Marcil

Hi,

Im trying to change the "IncludeText" values in a word document
throguh VB (VBA) , I need to change lot of word documents (nearly
500) , I could change the values of the "includtext" fields in the
document body using the following


' /// after opened the document
lcode = WordDoc.Fields(i).Code
If Left(lcode, 12) = " INCLUDETEXT" Then
newCode = Replace(lcode, "V:\\", "C:\\")
WordDoc.Fields(i).Code.Text = newCode
WordDoc.Fields(i).Update
End If
' // save and close document and word objects

but this code is not changing the "includetext" in the
footer..

This works:

Dim strField As String
Dim rgeFooter As Range
Dim i As Long

Set rgeFooter =
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range

i = 1
For i = 1 To rgeFooter.Fields.Count
With rgeFooter.Fields(i)
strField = .Code
If InStr(1, strField, "INCLUDETEXT") > 0 Then
strField = Replace(strField, "V:\\", "C:\\")
.Code.Text = strField
.Update
End If
End With
Next
 

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