Board index » cppbuilder » Excel Automation : the method "Move"

Excel Automation : the method "Move"

Hello,

I must move a Sheet after another one, but when i execute this code, Excel
doesn't exit :

_Worksheet *ws1 = 0;
 sheets->get_Item(TVariant(1),(LPDISPATCH *)&ws1);
newSheet.Bind(ws1);

_Worksheet *ws2 = 0;
 sheets2->get_Item(TVariant(sheets2->get_Count()),(LPDISPATCH *)&ws2);

newSheet.Move(TNoParam(),TVariant(ws2));

What can I put instead of TVariant(ws2) ?

Thanks,

Jo?lle Eustache.

 

Re:Excel Automation : the method "Move"


Change _Worksheet *ws1; to _Worksheet ws1;. i.e., you don't need to have
pointer variable as _Worksheet is a smart pointer.

hth,
.a

Quote
"Eustache Jo?lle" wrote:

[snip]

Re:Excel Automation : the method "Move"


_Worksheet is an abstract class...

Sorry,

Jo?lle Eustache.

"Alex Bakaev [TeamB]" <abak...@polycom.com> a crit dans le message news:
3ADF2464.54...@polycom.com...

Quote
> Change _Worksheet *ws1; to _Worksheet ws1;. i.e., you don't need to have
> pointer variable as _Worksheet is a smart pointer.

> hth,
> .a

> "Eustache Jo?lle" wrote:
> [snip]

Re:Excel Automation : the method "Move"


Ah, OK. In this case just use the IDispatch-based Worksheet wrapper. The
problem with your code is that the interface is not released. It will be
if you use a smart interface pointer. Search this group for an Excel
sample I posted.

.a

Quote
"Eustache Jo?lle" wrote:

[snip]

Re:Excel Automation : the method "Move"


Excuse me, but I don't understand what you mean. All my code is based on
your sample, and the method "Move" is really the problem because when I
comment it, my application exit normally.
How can I transform a Worksheet in a TVariant for this method ?

Thanks for your help, because I don't know what to do ....

Jo?lle Eustache

"Alex Bakaev [TeamB]" <abak...@polycom.com> a crit dans le message news:
3AE07479.1E39F...@polycom.com...

Quote
> Ah, OK. In this case just use the IDispatch-based Worksheet wrapper. The
> problem with your code is that the interface is not released. It will be
> if you use a smart interface pointer. Search this group for an Excel
> sample I posted.

> .a

> "Eustache Jo?lle" wrote:
> [snip]

Re:Excel Automation : the method "Move"


Well, I don't really know what's going on. The code snipped as you
posted it caused interface leaks - that would cause Excel not to close.
Now you are saying your applocation doesn't exit normally.

.a

Quote
"Eustache Jo?lle" wrote:

[snip]

Other Threads