Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default cannot get ListObject using C++

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);
}*/



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default cannot get ListObject using C++

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);
}*/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default cannot get ListObject using C++

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);
}*/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default cannot get ListObject using C++

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ListObject - XML question Raghu Excel Programming 0 February 16th 07 11:54 PM
ListObject binding samsam Excel Programming 0 September 19th 06 08:05 AM
Events for listobject sai Excel Programming 1 February 8th 05 12:23 AM
LISTOBJECT question Marek Excel Programming 0 September 5th 04 10:21 AM
listobject ... Excel2003 Jim C.[_4_] Excel Programming 0 April 3rd 04 10:13 PM


All times are GMT +1. The time now is 03:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"