views:

1433

answers:

3

What's the better way to insert cell comments in excel 2007 files programmaticaly using c# and .net 3.5?

A: 

Have you tried using VSTO ? You can easily load an Excel document and manipulate it. To add a comment to a cell, load the file, activate the worksheet, then select the cell as a range and set the comment.

Alexandre Brisebois
+4  A: 

I just did exactly that but with MS Word (using Microsoft.Office.Interop.Word

range.Comments.Add ( range, ref _categoryMessage );

So, I would suggest using Microsoft.Office.Interop.Excel and the similar method. Consider this from MSDN:

http://msdn.microsoft.com/es-es/library/microsoft.office.interop.excel.range.addcomment.aspx

Also see this too

kenny
probably need to play with the editor to get the whole link to work
Lance Roberts
Thanks, Kenny.But when i do this my program is starting a process called excel. Does it means i need to have ms excel installed on my computer?
Adones Cunha
Yes. Sorry, these interop calls require Excel.
kenny
Something also worth mentioning is that there are no Excel library redistributables when you use the Interop.Excel. So users of the application also need to have Excel installed on their machine.If you need to write the application for targets that don't have Excel installed locally, you need to modify the .xml directly. I believe there are some good utilities for this out there.
JettGeek
A: 

hi! have you solved it? i'm trying to add comments without using the VSTO and i can't achieve it. Could you help me? thanks! Ariel

Ariel