Comments Member on Worksheet Object

  • Thread starter Thread starter Matthew Wieder
  • Start date Start date
M

Matthew Wieder

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!
 
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.
--------------------
 
Back
Top