Excel VBA modifying Word document Header & Footer

marcellnoel26

New Member
Joined
Mar 20, 2020
Messages
1
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Good Afternoon,

I'm trying to modify my current code to replace specified words in a MS Word document. The whole idea is working but only for the body of the document and nothing happens in the header neither in the footer. Can you please advise me where am I wrong ?

Thank you in advance!

VBA Code:
Sub FindAndReplace(ByVal FindWord, ByVal ReplaceWord)

WordApp.ActiveDocument.Range.Find.Execute FindText:=FindWord, Wrap:=1, ReplaceWith:=ReplaceWord, Replace:=2
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi, and welcome to Mr. Excel.
This is an Excel forum, and whilst it does deal with a great deal of VBA, only Excel questions should be posed (I think!).
You should find a similar Word forum, and pose your question there. Offhand, I don't know any, but I've never checked...

That having been said, someone may come up with a solution for you.

Meanwhile, back at the Ranch, a quick Google search, (other search engines are available), revealed many threads, including this, which looked like a possible road to explore.
HTH
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top