Board index » delphi » Delphi6 controlling Excel & Word

Delphi6 controlling Excel & Word

I've got a Delphi6 program which works correctly controlling Excel97 and
Word97.  The program does not function correctly with Excel2000 and
Word2000.  In Delphi I am using units Excel97 and Word97; are these
compatible with Excel2000 and Word2000?

Any suggestions?

Harold

 

Re:Delphi6 controlling Excel & Word


<<Harold D. Ausfresser:
In Delphi I am using units Excel97 and Word97; are these
compatible with Excel2000 and Word2000?

Quote

Yes. What's going wrong?

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Delphi6 controlling Excel & Word


There are a number of problems; I'll describe one of them.  The program uses
15 Word templates with bookmarks. It replaces the bookmarks (including one
in the footer of each template) with the appropriate data. It then adds the
contents of the second document generated to the end of the first document.
It then adds the third document contents, etc.  The following code takes
care of the addition process:
procedure AddToCommonFile;
var
  ItemIndex, id, id1, break: OleVariant;
begin
  Routine := 'AddToCommonFile';
  ItemIndex := 1;
  id := wdStory;
  id1 := wdMove;
  break := wdSectionBreakNextPage;
  with DModOffice.WordAD do begin
    Range.WholeStory;
    Range.Copy;
  end;
  with DModOffice.WordApp do begin
    Windows.Item(ItemIndex).Activate;
    Selection.EndKey(id, id1);
    Selection.InsertBreak(break);
    Selection.paste;
  end;
end;
The first five documents are properly combined.  When this procedure is
called for the sixth document, I get an EOleException upon executing the
Selection.InsertBreak(break) statement:
"This method or property is not available because the object refers to a
header or footer."  If I comment out this statement the program runs without
any exceptions, but the resultant document does not include any document
contents after number 5.

Remember that this program operates reliably with Office97.

"Deborah Pate (TeamB)" <d.p...@cableinet.co.not-this-bit.uk> wrote in
message news:VA.00000f1e.00210c90@cableinet.co.not-this-bit.uk...

Quote
> <<Harold D. Ausfresser:
> In Delphi I am using units Excel97 and Word97; are these
> compatible with Excel2000 and Word2000?

> Yes. What's going wrong?

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   Use Borland servers; TeamB don't see posts via ISPs
>   http://www.borland.com/newsgroups/genl_faqs.html

Other Threads