Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kartechy@googlemail.com - 22 Feb 2008 16:24 GMT
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
Jean-Guy Marcil - 22 Feb 2008 17:12 GMT
> Hi,
>
[quoted text clipped - 14 lines]
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.