Board index » delphi » adding to MS Word Header

adding to MS Word Header


2004-11-26 07:55:07 PM
delphi148
Hi all,
I am having real trouble getting delphi to insert some text into the header
of a word doc !! Any Ideas ???
I have opened the Word doc using this
'code------------------------------------------
word := CreateOleObject('Word.Application');
try
word.Documents.Open(FileName := 'c:\aaa.doc', PasswordDocument :=
'qwerty');
'------added text using this
word.selection.typetext('hello')
'-------printed it
word.ActiveDocument.PrintOut;
word.Quit;
finally
word := UnAssigned;
end;
This all works fine but i just cant get it to write to the header section.
any help would be fantastic !!!!!!
Thanks
Martin Hayes
 
 

Re:adding to MS Word Header

word := CreateOleObject('Word.Basic');
word.ViewHeader;
word.CenterPara;
word.Insert('any header text');
word.ViewPage;
word.Insert('any body text');
word.FileSaveAs(FileName);
word.FileClose;
word.FileExit;
word := UnAssigned;
"Martin Hayes" <XXXX@XXXXX.COM>writes
Quote
Hi all,

I am having real trouble getting delphi to insert some text into the
header
of a word doc !! Any Ideas ???

I have opened the Word doc using this

'code------------------------------------------
word := CreateOleObject('Word.Application');
try
word.Documents.Open(FileName := 'c:\aaa.doc', PasswordDocument :=
'qwerty');

'------added text using this
word.selection.typetext('hello')

'-------printed it
word.ActiveDocument.PrintOut;
word.Quit;
finally
word := UnAssigned;
end;


This all works fine but i just cant get it to write to the header section.
any help would be fantastic !!!!!!

Thanks
Martin Hayes