Link to home
Start Free TrialLog in
Avatar of BemboX
BemboX

asked on

How to know if an Excel cell has a rectangle inside an its background color using vb.net

Dear experts:
I'm using Microsoft.Office.Interop.Excel to read an Excel file with vb.net. There is no problem with text or formulas but how can I know if a cell has a rectangle inside and what is the color of that rectangle?
Avatar of dimaj
dimaj
Flag of United States of America image

Try something like this:

"I got few experiences with Excel automation.
Let get back to the previous post and add this line.
Excel.Range range = ws.get_Range(ws.Cells[1,1],ws.Cells[1,2]);
range.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;"

Please note, this has been copied and pasted from this thread: http://bytes.com/topic/c-sharp/answers/252803-setting-excel-2003-borders-programmatically
Avatar of BemboX
BemboX

ASKER

Thanks for your answer but the rectangle is inside the cell, this is not a border.
so, that rectangle is an embedded image?
Avatar of BemboX

ASKER

I think it was created as a form (insert/form). I am attaching an example of an excel file with rectangles. Rectangles.xls
Thanks for that...

by the looks of it, that rectangle is not part of the cell... What you'll need to do is the following:
1) Get list of all objects on the worksheet
2) find the cell of interest and try to get that cell's coordinates
3) Loop through the list of your rectangles and see if a coordinate falls in a cell of interest.

If I'll find some code, I'll post it, but I hope this will at least give you some idea of where to start looking from.
ASKER CERTIFIED SOLUTION
Avatar of dimaj
dimaj
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BemboX

ASKER

Thanks for your answer, that code is helpful.
Glad to help :)