M
Mahmut Akbolat
I am using ole TOleContainer in Delphi and createing a word document and
adding fields in that way.
var
Val: Variant;
begin
Val := Edit1.Text;
OleContainer1.OleObject.Application.ActiveDocument.Variables.Add('FIELD_NAME
', Val);
end;
then manuallly adding fields from word like that.
Insert/Fields/Document Outomation/ Doc Variable /"FIELD_NAME" <OK>
then value of the variable display in the document then from my program
change the value of the field doing that:
var
Field: Variant;
begin
Field := 'FIELD_NAME';
OleContainer1.OleObject.Application.ActiveDocument.Variables.Item(Field).Val
ue := Edit1.Text;
OleContainer1.OleObject.Application.ActiveDocument.Fields.Update;
end;
After that line
OleContainer1.OleObject.Application.ActiveDocument.Fields.Update;
all the fields in the document getting updated but the fields on the header
and footer is not updated. How can I update the fields by code.
Then I found a method like this:
with OleContainer1 do
begin
OleObject.Application.ActiveWindow.ActivePane.View.SeekView :=
wdSeekCurrentPageFooter;
OleObject.Application.ActiveDocument.Select;
OleObject.Application.ActiveWindow.Selection.Fields.Update;
OleObject.Application.ActiveDocument.Fields.Update;
OleObject.Application.ActiveWindow.ActivePane.View.SeekView :=
wdSeekCurrentPageHeader;
OleObject.Application.ActiveDocument.Select;
OleObject.Application.ActiveWindow.Selection.Fields.Update;
OleObject.Application.ActiveDocument.Fields.Update;
end;
But this is not a effecient method and there must be a shorter way.
thanks for helps.
adding fields in that way.
var
Val: Variant;
begin
Val := Edit1.Text;
OleContainer1.OleObject.Application.ActiveDocument.Variables.Add('FIELD_NAME
', Val);
end;
then manuallly adding fields from word like that.
Insert/Fields/Document Outomation/ Doc Variable /"FIELD_NAME" <OK>
then value of the variable display in the document then from my program
change the value of the field doing that:
var
Field: Variant;
begin
Field := 'FIELD_NAME';
OleContainer1.OleObject.Application.ActiveDocument.Variables.Item(Field).Val
ue := Edit1.Text;
OleContainer1.OleObject.Application.ActiveDocument.Fields.Update;
end;
After that line
OleContainer1.OleObject.Application.ActiveDocument.Fields.Update;
all the fields in the document getting updated but the fields on the header
and footer is not updated. How can I update the fields by code.
Then I found a method like this:
with OleContainer1 do
begin
OleObject.Application.ActiveWindow.ActivePane.View.SeekView :=
wdSeekCurrentPageFooter;
OleObject.Application.ActiveDocument.Select;
OleObject.Application.ActiveWindow.Selection.Fields.Update;
OleObject.Application.ActiveDocument.Fields.Update;
OleObject.Application.ActiveWindow.ActivePane.View.SeekView :=
wdSeekCurrentPageHeader;
OleObject.Application.ActiveDocument.Select;
OleObject.Application.ActiveWindow.Selection.Fields.Update;
OleObject.Application.ActiveDocument.Fields.Update;
end;
But this is not a effecient method and there must be a shorter way.
thanks for helps.