Link to home
Start Free TrialLog in
Avatar of LauraPerez
LauraPerez

asked on

Delphi 5 and Word97 Automation

Hi, I use Delphi 5 and the word97 unit. I'm trying to formatting a word document ' s header and footer. I'd like to setting the LinkToPrevious property to True in every section on the Sections group.  
...
OleVar:= True;
y:=1;
while y <= wdDoc.Sections.Count  do
 begin
 WdDoc.Sections.Item(y).Headers.Item(wdHeaderFooterPrimary).LinkToPrevious:= OleVar;
 WdDoc.Sections.Item(y).Footers.Item(wdHeaderFooterPrimary).LinkToPrevious:= OleVar;
 WdDoc.Sections.Item(y).Headers.Item(wdHeaderFooterEvenPages).LinkToPrevious:= OleVar;
 WdDoc.Sections.Item(y).Footers.Item(wdHeaderFooterEvenPages).LinkToPrevious:= OleVar;
 y:= y+1;
 end;
....

If I Run the application an error ocurr when y refers to de last  section. The error message says something like: "Class Exception. This command is not available. ".
But if I Run using the 'Step Over (F8)' option from the debugger evrerythings ok, no error appear.
I'd like to know what am I doing wrong.

Any ideas please?

Thanks,

Laura
Avatar of BlackTigerX
BlackTigerX

this should give you a good start

http://www.djpate.freeserve.co.uk/AutoWord.htm
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial