I am replacing a name and date in the second-page header ("Primary Header" per Word) of a letter with the following code:
Set PriHdr = ActiveDocument.Sections(1). _
Headers(wdHeaderFooterPrimary).Range
With PriHdr.Find
.Text = "Name"
.Replacement.Text = sName
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
.Text = "Date"
.Replacement.Text = sDate
.Wrap = wdfindContinue
.Execute Replace:=wdReplaceAll
End With
This works fine except that it adds an extra Paragraph Mark after the replaced Date. I would like to delete the extra vbCr immediately after the date. But I don't know how to find out where I am within the header after the second (date) replacement. I tried:
Set PriHdr = PriHdr.Next(wdParagraph, 1)
but that got error msg. I'm really a newbie at VBA and am having a hard time always knowing how to tell where I am and how to get where I want to go... Any help would be appreciated. Thanks!
Set PriHdr = ActiveDocument.Sections(1). _
Headers(wdHeaderFooterPrimary).Range
With PriHdr.Find
.Text = "Name"
.Replacement.Text = sName
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
.Text = "Date"
.Replacement.Text = sDate
.Wrap = wdfindContinue
.Execute Replace:=wdReplaceAll
End With
This works fine except that it adds an extra Paragraph Mark after the replaced Date. I would like to delete the extra vbCr immediately after the date. But I don't know how to find out where I am within the header after the second (date) replacement. I tried:
Set PriHdr = PriHdr.Next(wdParagraph, 1)
but that got error msg. I'm really a newbie at VBA and am having a hard time always knowing how to tell where I am and how to get where I want to go... Any help would be appreciated. Thanks!