Board index » delphi » compatibility officexp <-> office 2000 <-> office 97

compatibility officexp <-> office 2000 <-> office 97


2004-11-22 10:09:14 PM
delphi187
Is it correct that I could make word and excel automation with the
dcloffice2k package that was working with office 97,
but I cannot make an application using dclofficexp that is working with
office 2000 ?
Ren?SSV
--
 
 

Re:compatibility officexp <-> office 2000 <-> office 97

<<Ren?Laursen:
Is it correct that I could make word and excel automation
with the dcloffice2k package that was working with office
97, but I cannot make an application using dclofficexp that
is working with office 2000 ?
Quote
>
If you use a later type library with an earlier Office
version, you have to be extremely careful not to use any of
the newly introduced interface methods. However it can be
done. What problems are you having?
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:compatibility officexp <-> office 2000 <-> office 97

Quote
If you use a later type library with an earlier Office
version, you have to be extremely careful not to use any of
the newly introduced interface methods. However it can be
done. What problems are you having?
I am performing a word mailmerge with an excel.file as datasource.
My problem is that when my app. uses dcloffice2k and the users are running
office 2003, they are getting an annoying prompt.
I have made a macro with word 2003 where the prompt is not popping up. This
macro I can only use with dclofficeXP and then it only works for office 2003
and XP. If I can detect wich version of office the user is running then I
can adjust the parameters to OpenDatasource so to use the old (2k) interface
when running 97/2k and the new interface when running 2003/XP
Can you tell me how to find the office-version ?
And could you tell me what is the difference between officeXP and
office2003 - if any ?
Ren?SSV
 

Re:compatibility officexp <-> office 2000 <-> office 97

Quote
the newly introduced interface methods. However it can be
done. What problems are you having?
The other thing I am doing is a simple print of an excel-file. And this is
worse since I am not using any new methods or anything:
ExcelApplication1.Connect;
try
LCID:= GetUserDefaultLCID;
Prt:= Printer.Printers[Printer.PrinterIndex];
Wbk.ConnectTo(ExcelApplication1.Workbooks.Open(Filename,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,
EmptyParam,EmptyParam, // XP addition
LCID));
ws:= Wbk.worksheets[1];
WS.Activate;
WS.PageSetup.LeftHeader:= Titel;
WS.PageSetup.RightHeader:= 'Udskrevet &D kl. &T';
WS.PageSetup.CenterFooter:= 'Side &S';
WS.PageSetup.Orientation:= xlLandscape;
WS.PageSetup.PrintGridLines:= true;
WS.PageSetup.Papersize:= xlPaperA4;
WS.PrintOut(EmptyParam,EmptyParam,1,EmptyParam,Prt);
finally
ExcelApplication1.DisplayAlerts[lcid]:= false;
Wbk.Close;
Wbk.Disconnect;
ExcelApplication1.Quit;
ExcelApplication1.Disconnect;
end;
This code doesn't work with office 2000 - I am getting "the class is not
registered". The only change I have done when going from dcloffice2k to
dclofficeXP is the 2 added EmptyParams !?
Ren?SSV
 

Re:compatibility officexp <-> office 2000 <-> office 97

<<Ren?Laursen:
Can you tell me how to find the office-version ?
Quote
>
Office application objects have a Version property, e.g.
Excel.Version[lcid], that you can use for this.
<<Ren?
And could you tell me what is the difference between
officeXP and office2003 - if any ?
Quote
>
Sorry, no - I am still on XP. But changes have to appear at
the end of interface declarations in new versions, making
them a bit easier to spot. (Old methods may be renamed in
new versions, but must have the same arguments and
position.)
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:compatibility officexp <-> office 2000 <-> office 97

<<Ren?Laursen:
The only change I have done when going from dcloffice2k to
dclofficeXP is the 2 added EmptyParams !?
Quote
>
Sending Excel2000 more parameters than it expects will
cause errors - if you're not using new XP methods, why not
use the Excel2000 type library, which will work with later
versions?
But "the class is not registered" sounds more like an
installation error.
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:compatibility officexp <-> office 2000 <-> office 97

"Deborah Pate (TeamB)" <XXXX@XXXXX.COM>skrev i en
meddelelse news:XXXX@XXXXX.COM...
Quote
<<Ren?Laursen:
The only change I have done when going from dcloffice2k to
dclofficeXP is the 2 added EmptyParams !?
>>

Sending Excel2000 more parameters than it expects will
cause errors - if you're not using new XP methods, why not
use the Excel2000 type library, which will work with later
versions?
Thank you for very quick answers !
Well I don't have to - but how do I use excel2000 and wordXP components
within the same app. ?
Quote
But "the class is not registered" sounds more like an
installation error.
I always get this error when trying to use word or excel on a PC where
office it is not installed.
And now I get the same error om my PC with office 2000 and my app. compiled
with dclofficeXP, so it was natural for me to think that it the differering
versions causing the error.
 

Re:compatibility officexp <-> office 2000 <-> office 97

<<Ren?Laursen:
Well I don't have to - but how do I use excel2000 and
wordXP components within the same app. ?
Quote
>
That would be trickier. :)
There are a few ways of working around that problem, and
which is best for you will depend on which new WordXP
features you use. So I will just give here some general
techniques for mixing office versions in an app.
1) Use the backwards-compatible versions of methods in the
later interfaces. In Excel, these methods start with _, e.g
the Workbooks._Open method. In Word, they are called things
like 'OpenOld'. The disadvantage with this method is that
you have to check for these methods, and you will get no help
from the compiler if you use a later method by mistake.
2) Use occasional late binding.
When you use late binding (i.e., you call an automation
method through a variant), the method is called by name, so
that 'Open' calls the correct method for each version - and
since you don't put in all the EmptyParams with late
binding, you won't supply too many. (Of course you will come
unstuck with this if you explicitly add a parameter that
only exists in later versions, without having checked that
the user has the right Office version first.) So e.g. you
could do:
var
VarWBKs: OleVariant;
..
VarWBKs := ExcelApplication1.Workbooks;
WBk.ConnectTo(IDispatch(VarWBks.Open(Filename)) as
_Workbook);
3) Use both type libraries.
You can have both ExcelXP and Excel2000 in your uses
clause; the one one that comes second will be the one that
the compiler uses unless you explicitly call the other,
e.g. after
uses
[...] ExcelXP, Excel2000;
you'd use
Excelapp.Workbooks.Open('E:\Book4.xls', [16 x
EmptyParam], lcid);
or
var
WBKs: ExcelXP.Workbooks;
..
WBKS := Excelapp.Workbooks as ExcelXP.Workbooks;
WBKs.Open('E:\Book4.xls', [18 x EmptyParam], lcid);
It's generally safer to use the earlier type libraries and
just use technique 2 or 3 for accessing the occasional
newer method. If you need to use newer events, you will need
to use the components for the later version and be careful.
:)
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:compatibility officexp <-> office 2000 <-> office 97

Quote
There are a few ways of working around that problem, and
which is best for you will depend on which new WordXP
features you use. So I will just give here some general
techniques for mixing office versions in an app.

and
Office application objects have a Version property, e.g.
Excel.Version[lcid], that you can use for this.
Thank you once again for very good and elaborate answers !
I can use the "_open" way of doing this.
Combined with a test for word-version when merging I can solve my problems.
But how do the strings returned by Excel..version[lcid] and
wordapplication.Version look like ?
/Ren?SSV
 

Re:compatibility officexp <-> office 2000 <-> office 97

<<Ren?Laursen:
But how do the strings returned by Excel..version[lcid] and
wordapplication.Version look like ?
Quote
>
Like numbers: '10.0', for my Office XP. (Office 95 was
version 7.)
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html