Word Automation - Update Footer/Header Fields

johnny_martins00johnny_martins00 Member Posts: 39
Hi,

I've searched and tried several ways but without sucess in order to update Header/Footers fields in a word template using Word Automation.

My template it's being correctly update on the document body, but when i try to update one of the Header/Footer the document doesn get updated..

Can anyone give me the exact sintax in order to achieve this?

Try 1

//wdApp.ActiveWindow.View.SeekView := 10;
//wdApp.ActiveWindow.Selection.SetRange(0,0);//select nothing
//IF wdApp.ActiveWindow.Selection.Find.Execute(SearchField) THEN //find and select
//  wdApp.ActiveWindow.Selection.TypeText:='Teste';//the actual replace

[b]Try 2[/b]
///wdApp.ActiveWindow.ActivePane.View.SeekView(10);
//wdApp.Selection.TypeText :='Teste';

etc...

Comments

  • johnny_martins00johnny_martins00 Member Posts: 39
    Hi,

    Does anyone had this type of problem, that can help me?

    Any help will be appreciated.

    Best Regards
    JM
  • johnny_martins00johnny_martins00 Member Posts: 39
    Hi,

    Solved this way:
    //Update Footer
    wdApp.ActiveWindow.ActivePane.View.SeekView(10);  //Go to Footer/Header
    SearchField :='SearchText';
    
    var_False := FALSE;
    var_True := TRUE;
    lint_Type1 := 1;
    lint_Type2 := 2;
    lint_Type3 := 1;
    ltxt_Type1 := '';
    varReplaceBy := 'ReplaceText';
    
    wdFind := wdApp.Selection.Find;
    wdFind.ClearFormatting;
    wdFind.Text(SearchField );
    wdFind.Replacement.ClearFormatting;
    wdFind.Replacement.Text(varReplaceBy);
    wdFind.Execute(SearchField,var_True,var_True,var_False,var_False,
          var_False,var_True,lint_Type1,var_False,varReplaceBy,lint_Type2,var_False,var_False,var_False,var_False);
    
     wdApp.ActiveWindow.ActivePane.View.SeekView(0); //Voltar ao Body
    

    Hope it helps someone

    Regards
    ´JM
  • mdPartnerNLmdPartnerNL Member Posts: 802
    nice
Sign In or Register to comment.