• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

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?
0
BemboX
Asked:
BemboX
  • 5
  • 3
1 Solution
 
dimajCommented:
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
0
 
BemboXAuthor Commented:
Thanks for your answer but the rectangle is inside the cell, this is not a border.
0
 
dimajCommented:
so, that rectangle is an embedded image?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
BemboXAuthor Commented:
I think it was created as a form (insert/form). I am attaching an example of an excel file with rectangles. Rectangles.xls
0
 
dimajCommented:
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.
0
 
dimajCommented:
0
 
BemboXAuthor Commented:
Thanks for your answer, that code is helpful.
0
 
dimajCommented:
Glad to help :)
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now