Search and Replace text in Header
Posted: Mon Jun 27, 2016 10:13 pm
I have this code for replacing text in a header and then in the body. But now some of my RTF files throw an index(0) error when trying to process info in the header.
i get an error on the RVHeader.SetSelectionBounds command of
List Index out of bounds (0) but not on the first time thru. 32nd time thru the searchandreplace it errors out. InSearch = '<HKL_01>' and InReplace = 'HKL, LLP'
Code: Select all
begin
rveDoc.RVHeader.SetSelectionBounds(
0, rveDoc.RVHeader.GetOffsBeforeItem(0),
0, rveDoc.RVHeader.GetOffsBeforeItem(0));
while (rveDoc.RVHeader.SearchText(InSearch,[RVEdit.TRVESearchOption.rvseoMatchCase,
RVEdit.TRVESearchOption.rvseoDown])) do
rveDoc.RVHeader.InsertText(InReplace, False);
end;
begin
rveDoc.ActiveEditor.SetSelectionBounds(
0, rveDoc.ActiveEditor.GetOffsBeforeItem(0),
0, rveDoc.ActiveEditor.GetOffsBeforeItem(0));
while (rveDoc.ActiveEditor.SearchText(InSearch,[RVEdit.TRVESearchOption.rvseoMatchCase,
RVEdit.TRVESearchOption.rvseoDown])) do
rveDoc.ActiveEditor.InsertText(InReplace, False);
end;
List Index out of bounds (0) but not on the first time thru. 32nd time thru the searchandreplace it errors out. InSearch = '<HKL_01>' and InReplace = 'HKL, LLP'