$word = Win32::OLE-> GetActiveObject('Word.Application') || Win32::OLE-> new('Word.Application','Quit'); my $Wordsections = $word->{Sections}; my $sections = $doc->{Sections}; my $n_sections = $sections->{Count}; for my $s ( 1 .. $n_sections ) { my $section = $sections->Item($s); my $headers = $section->{Headers}; my $n_headers = $headers->{Count}; for my $h ( 1 .. $n_headers ) { my $header = $headers->Item($h); print $header->{Range}->{Text}, "\n"; #my $headerRange=$headers->Range("wdHeaderFooterIndex")->InRange="TRUE"; $Wordsections->Find->ClearFormatting; $Wordsections->Find->{Text} = 'SECRET'; $Wordsections->Find->Replacement->{Text} = "NOFORN"; $Wordsections->Find->Execute({Replace => wdReplaceAll}); } my $footers = $section->{Footers}; my $n_footers = $footers->{Count}; for my $f ( 1 .. $n_footers ) { my $footer = $footers->Item($f); print $footer->{Range}->{Text}, "\n"; } }