From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d214e4af7a3eacfe X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!Spring.edu.tw!news.nctu.edu.tw!feeder.seed.net.tw!netnews!not-for-mail From: "bubble" Newsgroups: comp.lang.ada Subject: Re: GNATCOM interface with MS Excel, Word Date: Fri, 8 Jul 2005 09:55:10 +0800 Organization: HiNetNews Message-ID: References: NNTP-Posting-Host: 211-21-128-195.hinet-ip.hinet.net X-Trace: netnews.hinet.net 1120787713 29262 211.21.128.195 (8 Jul 2005 01:55:13 GMT) X-Complaints-To: usenet@HiNetnews.hinet.net NNTP-Posting-Date: Fri, 8 Jul 2005 01:55:13 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Response Xref: g2news1.google.com comp.lang.ada:11957 Date: 2005-07-08T09:55:10+08:00 List-Id: hi Rebecca: this is sample code , I have test it in Offce 2003 I got only problem is the 3rd parameter in create method. the default gnatcom for the 3rd is CLSCTX_ALL, in most case,it work fine but in excel ,you must change 3rd parameter to CLSCTX_LOCAL_SERVER. DO NOT USE GANTCOM 's DEFAULT VALUE with Excel11.Workbooks_Interface; with Excel11.uWorkbook_interface; with Excel11.Application_Interface; with Excel11.uApplication_Interface; with Excel11.Sheets_Interface; with Gnatcom.Initialize; with Gnatcom.types; with gnatcom.variant; with gnatcom.dispinterface; with Interfaces.C; use Interfaces.C; procedure TestExcel is app : Excel11.uApplication_Interface.uApplication_Type; wbs : Excel11.Workbooks_Interface.Workbooks_Type; wb : Excel11.uWorkbook_interface.uWorkBook_type; sheets:Excel11.Sheets_Interface.Sheets_Type; sheet:gnatcom.dispinterface.dispinterface_type; cellRange:gnatcom.dispinterface.dispinterface_type; use Excel11; use gnatcom.types; use gnatcom; begin Gnatcom.Initialize.Initialize_COM; uApplication_Interface.create( app, "Excel.Application", CLSCTX_LOCAL_SERVER); uApplication_Interface.Put_Visible( app, 0, VARIANT_BOOL_TRUE); Workbooks_Interface.Attach( wbs, uApplication_Interface.Get_Workbooks(app) ); uWorkbook_interface.Attach(wb, Workbooks_Interface.Add(this=>wbs, lcid=>0) ); Sheets_Interface.Attach(sheets, uWorkbook_interface.Get_Worksheets(this=>wb) ); dispinterface.Attach( sheet, Sheets_Interface.Add(this=>sheets,lcid=>0) ); declare retValue:gnatcom.types.variant; a1:dispinterface.Parameter_Array:= ( 1=> gnatcom.variant.To_Variant("A1") ); begin retValue :=dispinterface.Get(sheet,"Range",a1); dispinterface.attach( cellrange, gnatcom.variant.To_Pointer_To_IDispatch(retValue) ); end; dispinterface.put( cellrange, "value", gnatcom.variant.To_VARIANT("ada call excel") ); Gnatcom.Initialize.uninitialize_COM; end testExcel;