J
Jim Jackson
I have been creating and updating a Word document from my Delphi 6 program.
With Word 2002 (Office 10) I cannot figure out what my
problem is. The following code works with the previous version of Word but
not with 2002. All I am trying to do is replace one font color with
another.
procedure FinalizeWrdRange(Range: Word2000.Range);
var
v1, v2, v3, v4, v5, v6: OleVariant; // for Ole parameter passing
begin
Range.WholeStory;
Range.Find.ClearFormatting;
Range.Find.Font.Color := wdColor Pink; // <--- fails on this
line
Range.Find.Replacement.ClearFormatting;
Range.Find.Replacement.Font.Color := wdColorSkyBlue;
v1 := '';
v2 := wdFindContinue;
v3 := True;
v4 := '';
v5 := wdReplaceAll;
v6 := True;
Range.Find.Execute(v1, EmptyParam, EmptyParam, v6, EmptyParam,
EmptyParam, EmptyParam, v2, v3, v4, v5, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);
end;
When tracing the code I get
Range.Find.Font = nil
and Range.Find.Replacement = nil
Do I have to start instantiating a Font and Replacement objects and assign
them? If so how?
Any ideas?
TIA,
Jim
With Word 2002 (Office 10) I cannot figure out what my
problem is. The following code works with the previous version of Word but
not with 2002. All I am trying to do is replace one font color with
another.
procedure FinalizeWrdRange(Range: Word2000.Range);
var
v1, v2, v3, v4, v5, v6: OleVariant; // for Ole parameter passing
begin
Range.WholeStory;
Range.Find.ClearFormatting;
Range.Find.Font.Color := wdColor Pink; // <--- fails on this
line
Range.Find.Replacement.ClearFormatting;
Range.Find.Replacement.Font.Color := wdColorSkyBlue;
v1 := '';
v2 := wdFindContinue;
v3 := True;
v4 := '';
v5 := wdReplaceAll;
v6 := True;
Range.Find.Execute(v1, EmptyParam, EmptyParam, v6, EmptyParam,
EmptyParam, EmptyParam, v2, v3, v4, v5, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);
end;
When tracing the code I get
Range.Find.Font = nil
and Range.Find.Replacement = nil
Do I have to start instantiating a Font and Replacement objects and assign
them? If so how?
Any ideas?
TIA,
Jim