replace text in multiple footer and/or primary footer word vba -


i wanted replace text in footer of word doc. docs might have primary header , footer, have multiple headers , footers.

here's code:

sub changedate()       selection.homekey unit:=wdstory      activewindow.activepane.view.seekview = wdseekcurrentpagefooter      check1:      selection.find         .text = "dec 01, 2015"         .replacement.text = "dec 01, 2015"         .forward = true         .wrap = wdfindask         .format = false         .matchcase = false         .matchwholeword = false         .matchwildcards = false         .matchsoundslike = false         .matchallwordforms = false     end     selection.find.execute replace:=wdreplaceall        activewindow.activepane.view.nextheaderfooter     on error goto cont          goto check1   cont:     activewindow.activepane.view.seekview = wdseekmaindocument   end sub 

on multiple footer documents works fine, if 1 footer available shows error.

you need move on error line in code. otherwise, when next footer, none found , error takes place before code reads line how handle errors.

edit: for each wdprimaryfooterstory in activedocument.storyranges (not sure exact syntax on should help: http://word.mvps.org/faqs/customization/replaceanywhere.htm


Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -