Board index » delphi » compatibility officexp <-> office 2000 <-> office 97
Ren?Laursen
![]() Delphi Developer |
Ren?Laursen
![]() Delphi Developer |
compatibility officexp <-> office 2000 <-> office 972004-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 -- |
Deborah Pate (TeamB)
![]() Delphi Developer |
2004-11-22 10:33:38 PM
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> 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 |
Ren?Laursen
![]() Delphi Developer |
2004-11-23 04:41:26 PM
Re:compatibility officexp <-> office 2000 <-> office 97QuoteIf you use a later type library with an earlier Office 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 |
Ren?Laursen
![]() Delphi Developer |
2004-11-23 04:53:29 PM
Re:compatibility officexp <-> office 2000 <-> office 97Quotethe newly introduced interface methods. However it can be 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 |
Deborah Pate (TeamB)
![]() Delphi Developer |
2004-11-23 05:28:07 PM
Re:compatibility officexp <-> office 2000 <-> office 97
<<Ren?Laursen:
Can you tell me how to find the office-version ? Quote> <<Ren? And could you tell me what is the difference between officeXP and office2003 - if any ? Quote> 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 |
Deborah Pate (TeamB)
![]() Delphi Developer |
2004-11-23 05:35:10 PM
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> 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 |
Ren?Laursen
![]() Delphi Developer |
2004-11-23 05:37:38 PM
Re:compatibility officexp <-> office 2000 <-> office 97
"Deborah Pate (TeamB)" <XXXX@XXXXX.COM>skrev i en
meddelelse news:XXXX@XXXXX.COM... Quote<<Ren?Laursen: within the same app. ? QuoteBut "the class is not registered" sounds more like an 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. |
Deborah Pate (TeamB)
![]() Delphi Developer |
2004-11-24 01:21:52 AM
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> 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 |
Ren?Laursen
![]() Delphi Developer |
2004-11-24 06:19:45 PM
Re:compatibility officexp <-> office 2000 <-> office 97QuoteThere are a few ways of working around that problem, and 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 |
Deborah Pate (TeamB)
![]() Delphi Developer |
2004-11-24 09:44:52 PM
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> -- 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 |