Help! I am trying to automate autocorrect entries that are in rich text format stored in access db.
It works fine if I use autocorrect.entries.Add but fails with autocorrect.entries.AddRichText. Look at the code below. I would appreciate your help!
procedure TfrmdxForm.acBtnClick(Sender: TObject);
var
DXRANGE, DXWORD: oleVariant;
DXSTR: STRING;
begin
DXWORD := CreateOleObject('Word.Application');
DXWORD.Visible := FALSE;
MyADODataSet.First;
while NOT MyADODataSet.Eof do
begin
DXRANGE:= MyADODataSet.FieldByName('DX').Text;
// here is where it fails … I don't know how to change this to a range
DXSTR := MyADODataSet.FieldByName('DXCODE').Text;
DXWORD.Autocorrect.Entries.AddRichText(DXSTR, DXRANGE);
// here it works if I use Add but it fails with AddRichText
MyADODataSet.Next;
end;
DXWORD.QUIT;
end;
Did you read carefully the documentation on MSDN regarding Add and AddRichText?
Add has two Parameters
AddRichText has also two Parameters
So you have to place the desired text inside the document, then select it (or try to get it in a range e.g. Paragraph) and after that you can use the AddRichText method