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

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -