On Jan 24, 4:48 am, toth.use...@gmail.com wrote:
> hi,
>
> i have a vba script which will modify the header text just as desired
> (e.g. to Chapter). however, i would also need to modify the content
Show us the relevant code.
toth.usenet@gmail.com - 04 Feb 2008 09:21 GMT
hi david,
sorry for the late reply, i can't always access the newsgroups.
the code i have is the following:
Dim oPrg As Paragraph
Dim rTmp As Range
For Each oPrg In ActiveDocument.Paragraphs
Set rTmp = oPrg.Range
With rTmp.Find
.Text = "\"
.Forward = False '!
While .Execute
rTmp.Start = oPrg.Range.Start
rTmp.Select ' for testing
rTmp.Text = ""
Wend
End With
Next
i hoped that i could re-use the same code but using
ActiveDcoument.Field instead of the paragraphs. however, when i tried
it it failed which i'm not surprised about as i have the feeling a
slightly different approach would need to be taken. any ideas?
thanks for your help,
thomas
> On Jan 24, 4:48 am, toth.use...@gmail.com wrote:
>
[quoted text clipped - 4 lines]
>
> Show us the relevant code.
David Sisson - 04 Feb 2008 16:56 GMT
Try this
Sub ReplaceXETextInFields()
Dim aDoc As Document
Dim MyField As Field
Set aDoc = ActiveDocument
For Each MyField In aDoc.Fields
If MyField.Type = wdFieldIndexEntry Then
MyField.Select
With Selection.Find
.Text = "Header\Title\Chapter"
.Replacement.Text = "Chapter"
.Forward = True
.Wrap = wdFindStop
.Format = False
.Execute Replace:=wdReplaceAll
End With
End If
Next
End Sub