Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

error when implement COM service to ms excel use twapi extenson!!

50 views
Skip to first unread message

rolance

unread,
Oct 28, 2008, 1:13:06 AM10/28/08
to
Dear All

Recently I get Tcl Windows API extension 2.0.12 and try some example
to MS EXCEL ( from http://twapi.magicsplat.com/). It didn't work --->
why ???

code:

package require twapi

set xl [twapi::comobj Excel.Application]
$xl Visible true
set workbooks [$xl Workbooks]
set workbook [$workbooks Add]
set sheets [$workbook Sheets]
set sheet [$sheets Item 1]
set cells [$sheet range a1 c3]
$cells Value 12345
$cells -destroy
$sheet -destroy
$sheets -destroy
$workbook -destroy
$workbooks -destroy
$xl Quit
$xl -destroy

error message:

occur exception condition。
while executing

"twapi::IDispatch_Invoke _5cb81700_p_IDispatch {6 {} 0 2 12 {{12 17}}}
12345"
("uplevel" body line 1)
invoked from within
"DbgNub_uplevelCmd DbgNub_uplevelCmd $args"
invoked from within
"uplevel 1 [list twapi::IDispatch_Invoke $ifc $prototype] $args"
(procedure "twapi::idispatch_invoke" line 7)
invoked from within
"twapi::idispatch_invoke _5cb81700_p_IDispatch {6 {} 0 2 12 {{12 17}}}
12345"
("eval" body line 1)
invoked from within
"eval [list twapi::idispatch_invoke $ifc
$::twapi::idispatch_prototypes($ifc,$name,0,$flags)] $params"
(procedure "::twapi::_comobj_wrapper" line 342)
invoked from within
"$cells Value 12345"


Could some one give me some direction to solve this error?

My platform: windows XP3
Tcl rev. 8.4.18.0

BR
Rolance

APN

unread,
Oct 28, 2008, 12:51:40 PM10/28/08
to
Try using the Value2 method instead of Value. Not quite sure what the
exact issue is as I don't automate Excel but somewhere between Excel
2000 and Excel 2007, this issue has cropped up.

Alternately, you could try using the Tcom extension instead of twapi
to see if that works better for the Value method.

Also, please do not post in multiple threads.

/Ashok

rolance wrote:
> Dear All
>
> Recently I get Tcl Windows API extension 2.0.12 and try some example
> to MS EXCEL ( from http://twapi.magicsplat.com/). It didn't work --->
> why ???
>
> code:
>
> package require twapi
>
> set xl [twapi::comobj Excel.Application]
> $xl Visible true
> set workbooks [$xl Workbooks]
> set workbook [$workbooks Add]
> set sheets [$workbook Sheets]
> set sheet [$sheets Item 1]
> set cells [$sheet range a1 c3]
> $cells Value 12345
> $cells -destroy
> $sheet -destroy
> $sheets -destroy
> $workbook -destroy
> $workbooks -destroy
> $xl Quit
> $xl -destroy
>
> error message:
>

> occur exception condition $B!# (B

rolance

unread,
Oct 28, 2008, 11:54:51 PM10/28/08
to
On 10月29日, 上午12時51分, APN <palm...@yahoo.com> wrote:
> Try using the Value2 method instead of Value. Not quite sure what the
> exact issue is as I don't automate Excel but somewhere between Excel
> 2000 and Excel 2007, this issue has cropped up.
>
> Alternately, you could try using the Tcom extension instead of twapi
> to see if that works better for the Value method.
>
> Also, please do not post in multiple threads.
>
> /Ashok
>
>
>
> rolance wrote:
> > Dear All
>
> > Recently I get Tcl Windows API extension 2.0.12 and try some example
> > to MS EXCEL ( fromhttp://twapi.magicsplat.com/). It didn't work --->

> > why ???
>
> > code:
>
> > package require twapi
>
> > set xl [twapi::comobj Excel.Application]
> > $xl Visible true
> > set workbooks [$xl Workbooks]
> > set workbook [$workbooks Add]
> > set sheets [$workbook Sheets]
> > set sheet [$sheets Item 1]
> > set cells [$sheet range a1 c3]
> > $cells Value 12345
> > $cells -destroy
> > $sheet -destroy
> > $sheets -destroy
> > $workbook -destroy
> > $workbooks -destroy
> > $xl Quit
> > $xl -destroy
>
> > error message:
>
> > occur exception condition。

> > while executing
>
> > "twapi::IDispatch_Invoke _5cb81700_p_IDispatch {6 {} 0 2 12 {{12 17}}}
> > 12345"
> > ("uplevel" body line 1)
> > invoked from within
> > "DbgNub_uplevelCmd DbgNub_uplevelCmd $args"
> > invoked from within
> > "uplevel 1 [list twapi::IDispatch_Invoke $ifc $prototype] $args"
> > (procedure "twapi::idispatch_invoke" line 7)
> > invoked from within
> > "twapi::idispatch_invoke _5cb81700_p_IDispatch {6 {} 0 2 12 {{12 17}}}
> > 12345"
> > ("eval" body line 1)
> > invoked from within
> > "eval [list twapi::idispatch_invoke $ifc
> > $::twapi::idispatch_prototypes($ifc,$name,0,$flags)] $params"
> > (procedure "::twapi::_comobj_wrapper" line 342)
> > invoked from within
> > "$cells Value 12345"
>
> > Could some one give me some direction to solve this error?
>
> > My platform: windows XP3
> > Tcl rev. 8.4.18.0
>
> > BR
> > Rolance- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

Hi Ashok

Thank for your advice! value2 ---> worked

Could you give me some link to get the newest MS EXCLE or MS WORD
function parameter list (syntax)?


thank

BR
Rolance

APN

unread,
Oct 29, 2008, 10:15:17 AM10/29/08
to

Sorry, I don't have a reference. Google is your friend. Or you go to
the Microsoft msdn site.

/Ashok

0 new messages