This is what I'm doing now to merge. I'll also need to do this for a character counting procedure since GetTextLen doesn't count headers or footers. Is there a way to loop through the available HeaderFooterTextRanges without having to try every possible one there might be? This works but seems damn inefficient. I don't have the footers in there yet but they will be added as well.
Code
procedure Tvariableform.MergeDoc;
begin
mainform.WPRichText1.WorkOnText := wpBody;
mainform.WPRichText1.MergeText;
mainform.WPRichText1.HeaderFooterTextRange:=wpraOnOddPages;
mainform.WPRichText1.WorkOnText := wpHeader;
mainform.WPRichText1.MergeText;
mainform.WPRichText1.HeaderFooterTextRange:=wpraOnEvenPages;
mainform.WPRichText1.WorkOnText := wpHeader;
mainform.WPRichText1.MergeText;
mainform.WPRichText1.HeaderFooterTextRange:=wpraOnFirstPage;
mainform.WPRichText1.WorkOnText := wpHeader;
mainform.WPRichText1.MergeText;
mainform.WPRichText1.HeaderFooterTextRange:=wpraOnLastPage;
mainform.WPRichText1.WorkOnText := wpHeader;
mainform.WPRichText1.MergeText;
mainform.WPRichText1.HeaderFooterTextRange:=wpraNotOnFirstAndLastPages;
mainform.WPRichText1.WorkOnText := wpHeader;
mainform.WPRichText1.MergeText;
mainform.WPRichText1.HeaderFooterTextRange:=wpraOnAllPages;
mainform.WPRichText1.WorkOnText := wpHeader;
mainform.WPRichText1.MergeText;
mainform.WPRichText1.WorkOnText := wpFooter;
mainform.WPRichText1.MergeText;
mainform.WPRichText1.WorkOnText := wpBody;
mainform.WPRichText1.Refresh;
end;
Alles anzeigen