Can't replace the footer text in a word applic

2019-07-19 17:42发布

问题:

I am trying to replace text in a footer, I am using the following code through which i can replace the normal content (body) but not the content in the footer/header

myWinWordApp := CreateOLEObject('Word.Application');
myWinWordApp.visible := true;
myWinWordApp.documents.open('c:\ole.doc');
myWinWordApp.Selection.Find.Text :=  'oo';
myWinWordApp.selection.Find.Replacement.Text := 'aa';
myWinWordApp.Selection.Find.Execute(Replace := 2);

any help is highly appreciated. Thanks in advance

回答1:

Made comment into answer:

I would try to set the view to the header/footer mode, maybe by doing something like ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader as shown here.