PC Review


Reply
Thread Tools Rate Thread

cannot get ListObject using C++

 
 
=?Utf-8?B?aGFpeWluZw==?=
Guest
Posts: n/a
 
      26th Apr 2007
Hi there,
I want to show the autofilter button programmatically from C++ application.
However, I cannot get it work yet. Eveen worse, I am not able to get the
ListObject.
I used the following code. Looks like I got the lists correctly, however,
GetCount() always return me zero. and listObj run into an error. I do have
some data in the sheet.
Any suggestion will be highly appreciated.

ListObjects lists;
ListObject listObj;

lists=objSheet.GetListObjects();
int num=lists.GetCount();

/*
for(i=0;i<(int)num;i++)
{
ListObject listObj=lists.GetItem(COleVariant((short)i));
listObj.SetShowAutoFilter(TRUE);
}*/



 
Reply With Quote
 
 
 
 
=?Utf-8?B?dXJrZWM=?=
Guest
Posts: n/a
 
      27th Apr 2007
I am not familiar with C++, buth with C# syntax I used something like this:


Excel.ListObjects lists;
lists = objSheet.ListObjects;

Console.WriteLine (lists.Count);

Excel.ListObject list;
list = lists.get_Item (1);

list.ShowAutoFilter = false;

Console.WriteLine (list.Name);


etc.



--
urkec


"haiying" wrote:

> Hi there,
> I want to show the autofilter button programmatically from C++ application.
> However, I cannot get it work yet. Eveen worse, I am not able to get the
> ListObject.
> I used the following code. Looks like I got the lists correctly, however,
> GetCount() always return me zero. and listObj run into an error. I do have
> some data in the sheet.
> Any suggestion will be highly appreciated.
>
> ListObjects lists;
> ListObject listObj;
>
> lists=objSheet.GetListObjects();
> int num=lists.GetCount();
>
> /*
> for(i=0;i<(int)num;i++)
> {
> ListObject listObj=lists.GetItem(COleVariant((short)i));
> listObj.SetShowAutoFilter(TRUE);
> }*/
>
>
>

 
Reply With Quote
 
=?Utf-8?B?aGFpeWluZw==?=
Guest
Posts: n/a
 
      27th Apr 2007
Hi urkec,

Thanks a lot for your reply.
I saw the only difference is console.writeline()
Will your code work without this line? If no, I need to find out what is
the corresponding C++ function. I am not familiar with C# :<)
In my case, lists.count always give me zero somehow and get_item(0) run into
a system error.

haiying
"urkec" wrote:

> I am not familiar with C++, buth with C# syntax I used something like this:
>
>
> Excel.ListObjects lists;
> lists = objSheet.ListObjects;
>
> Console.WriteLine (lists.Count);
>
> Excel.ListObject list;
> list = lists.get_Item (1);
>
> list.ShowAutoFilter = false;
>
> Console.WriteLine (list.Name);
>
>
> etc.
>
>
>
> --
> urkec
>
>
> "haiying" wrote:
>
> > Hi there,
> > I want to show the autofilter button programmatically from C++ application.
> > However, I cannot get it work yet. Eveen worse, I am not able to get the
> > ListObject.
> > I used the following code. Looks like I got the lists correctly, however,
> > GetCount() always return me zero. and listObj run into an error. I do have
> > some data in the sheet.
> > Any suggestion will be highly appreciated.
> >
> > ListObjects lists;
> > ListObject listObj;
> >
> > lists=objSheet.GetListObjects();
> > int num=lists.GetCount();
> >
> > /*
> > for(i=0;i<(int)num;i++)
> > {
> > ListObject listObj=lists.GetItem(COleVariant((short)i));
> > listObj.SetShowAutoFilter(TRUE);
> > }*/
> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?dXJrZWM=?=
Guest
Posts: n/a
 
      28th Apr 2007
I think writeline is the same as cout, so the code works without it. I get
the reference to listObjects collection using listObjects property of the
Worksheet object. Is objSheet.GetListObjects()function you used same as
objSheet.ListObjects property?
--
urkec


"haiying" wrote:

> Hi urkec,
>
> Thanks a lot for your reply.
> I saw the only difference is console.writeline()
> Will your code work without this line? If no, I need to find out what is
> the corresponding C++ function. I am not familiar with C# :<)
> In my case, lists.count always give me zero somehow and get_item(0) run into
> a system error.
>
> haiying
> "urkec" wrote:
>
> > I am not familiar with C++, buth with C# syntax I used something like this:
> >
> >
> > Excel.ListObjects lists;
> > lists = objSheet.ListObjects;
> >
> > Console.WriteLine (lists.Count);
> >
> > Excel.ListObject list;
> > list = lists.get_Item (1);
> >
> > list.ShowAutoFilter = false;
> >
> > Console.WriteLine (list.Name);
> >
> >
> > etc.
> >
> >
> >
> > --
> > urkec
> >
> >
> > "haiying" wrote:
> >
> > > Hi there,
> > > I want to show the autofilter button programmatically from C++ application.
> > > However, I cannot get it work yet. Eveen worse, I am not able to get the
> > > ListObject.
> > > I used the following code. Looks like I got the lists correctly, however,
> > > GetCount() always return me zero. and listObj run into an error. I do have
> > > some data in the sheet.
> > > Any suggestion will be highly appreciated.
> > >
> > > ListObjects lists;
> > > ListObject listObj;
> > >
> > > lists=objSheet.GetListObjects();
> > > int num=lists.GetCount();
> > >
> > > /*
> > > for(i=0;i<(int)num;i++)
> > > {
> > > ListObject listObj=lists.GetItem(COleVariant((short)i));
> > > listObj.SetShowAutoFilter(TRUE);
> > > }*/
> > >
> > >
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ListObject -> XML question =?Utf-8?B?UmFnaHU=?= Microsoft Excel Programming 0 16th Feb 2007 11:54 PM
ListObject binding =?Utf-8?B?c2Ftc2Ft?= Microsoft Excel Programming 0 19th Sep 2006 08:05 AM
listobject issue =?Utf-8?B?a2V2aW5j?= Microsoft Excel Programming 1 26th Apr 2006 02:28 PM
Events for listobject sai Microsoft Excel Programming 1 8th Feb 2005 12:23 AM
listobject ... Excel2003 Jim C. Microsoft Excel Programming 0 3rd Apr 2004 10:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:14 PM.