From: "bubble" <bubble@riskm.com.tw>
Subject: Re: GNATCOM interface with MS Excel, Word
Date: Fri, 8 Jul 2005 09:55:10 +0800
Date: 2005-07-08T09:55:10+08:00 [thread overview]
Message-ID: <dakme0$sie$1@netnews.hinet.net> (raw)
In-Reply-To: WC9te.2228$hV3.850@nntpserver.swip.net
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;
prev parent reply other threads:[~2005-07-08 1:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-19 8:01 GNATCOM interface with MS Excel, Word Rebecca & Firinde
2005-06-19 14:08 ` Stephen Leake
2005-06-19 19:16 ` tmoran
2005-06-19 20:17 ` Jeff Creem
2005-06-19 22:36 ` tmoran
2005-06-21 6:17 ` Frank Piron
2005-07-08 1:55 ` bubble [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox