2

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

Vijay Bobba
  • 313
  • 4
  • 15
  • 1
    That's not Delphi code... At any rate, 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](http://www.your-save-time-and-improve-quality-technologies-online-resource.com/vba-word-footer-and-header.html) – Andreas Rejbrand Apr 12 '11 at 15:29
  • 2
    @Andreas That is Delphi code. It's a late bound named parameter. – David Heffernan Apr 12 '11 at 15:42
  • @David: Yes, you are right. I must read up on variants... (Slightly embarrassed!) – Andreas Rejbrand Apr 12 '11 at 15:44
  • @Andreas: Thanks for your comment it helped me, i added the following line and it works myWinWordApp.ActiveWindow.ActivePane.View.SeekView := 10; // footer – Vijay Bobba Apr 12 '11 at 15:49

1 Answers1

7

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.

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384