ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comments Member on Worksheet Object (https://www.excelbanter.com/excel-programming/275639-comments-member-worksheet-object.html)

Matthew Wieder

Comments Member on Worksheet Object
 
The following C# code:

Excel.Comments tmpComments = m_TargetWorksheet.Comments;
foreach(Excel.Comment tmpComment in tmpComments)
{
tmpComment.Delete();
}

Fails with a "Member not found." exception, whether the worksheet has
comments in it or not. The same call in VBA works fine whether the
workbook has comments or not.
I'm using the Office 2002 PIAs for automation. Does anyone know why the
Comments member is not recognized?
thanks!


Peter Huang [MSFT]

Comments Member on Worksheet Object
 
Hi Matthew,

You may try to use a for statement instead.
e.g.
Excel.Comments tmpComments = m_TargetWorksheet.Comments;
for(int i=1; i<=tmpComments.Count;++i)
{
tmpComments.Item(i).Delete();
}

You may have a try and let me if it does the job for you.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
Message-ID:
Date: Fri, 29 Aug 2003 11:06:46 -0400
From: Matthew Wieder
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2)

Gecko/20030208 Netscape/7.02
X-Accept-Language: en-us, en, he
MIME-Version: 1.0
Subject: Comments Member on Worksheet Object
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Newsgroups: microsoft.public.excel.programming
NNTP-Posting-Host: 207.106.112.178
Lines: 1
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.programming:411238
X-Tomcat-NG: microsoft.public.excel.programming

The following C# code:

Excel.Comments tmpComments = m_TargetWorksheet.Comments;
foreach(Excel.Comment tmpComment in tmpComments)
{
tmpComment.Delete();
}

Fails with a "Member not found." exception, whether the worksheet has
comments in it or not. The same call in VBA works fine whether the
workbook has comments or not.
I'm using the Office 2002 PIAs for automation. Does anyone know why the
Comments member is not recognized?
thanks!





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com