Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recognizing Pics in cell

Status
Not open for further replies.

centaur21

Technical User
Oct 3, 2006
10
US
I was wondering if it were possible to have a pic (jpeg or other format) put into a cell and write a macro that would recognize the pic in the cell?

If this is possible and you know of a location on the internet that explains how to do this, I would appreciate it. Thanks.
 




Hi,

What do you mean by "recognize"?

The pics are in the Shapes collection of the Worksheet object. Each Shape Object in the Shapes Collection has properties, such as Type, that describe the Shape and the location of the Shape.

Please explain what you are trying to do.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
I am trying to take a jpeg pic, which is a light bulb (working on a program that calculates voltage drop for each light fixture in the circuit), and write some code that when my code searches through each cell and gets to the picture of the light bulb in the cell, it will do calculations or whatever I have programmed it to do.

I can insert pics into the excel sheet, but the pic floats and the sheet would not recognize it was there b/c it is not bound to any particular cell. I hope this clears it up some. So, basically what I want my program to do is the same as if I typed in the word "Hello" into a cell and use a For loop to search each cell for the word "Hello" and when it finds it, add 2+2 for example. But I want to do this using a picture instead of the word "Hello". Not sure if this is possible, but thought I would throw this question out there. Thanks SkipVought!
 
At the very least, you could put specific text in each cell that contains the lightbulb (assuming that the lightbulb pic is large enough to cover the text). When you use your For loop to search each cell, have it locate that text. You should know that for each instance that specific text is found in a cell, there is a picture of a lightbulb on that cell.

Hope this helps,
Matt
 
I thought of that SkipVought, but was hoping for something that would allow me to do this. This spreadsheet I am creating may be used by others and would like it to be user friendly and not have to enter any information except key info such as starting voltage, wire size, etc.... I have written the majority of the code to do this but am trying to make it a little more graphic. What I would really like it to do is allow the user to create their own circuit of lights by clicking on a cell with a drop down box and giving them the choice to choose a pic of a light, condulet junction box, cable connecting b/t each light or to a junction box. I may just have to do this with actual text though. I will look into other options though. Thanks again.
 
I'll take that as a compliment!!! I will be happy if I ever know half of what Skip knows about VBA!

I am sure there is a way to do exactly what you are looking for. From what you describe in this last post, I now see why my suggestion would not be ideal.

Best of luck in finding the solution.
 


Give each of these shapes a BASE NAME like LightBulb. Each of these shapes will then have a name like, LightBulb1, LightBulb2, etc.

Each shape has a TopLeft property, that is a Cell reference.
Code:
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
  If Left(shp.Name, 9) = "LightBulb" Then
    MsgBox shp.Name & " is in row " & shp.TopLeftCell.Row & " col " & shp.TopLeftCell.Column
  End If
Next
[code]


Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
[b]Small Medium at Large[/b][tongue][/sub]
 
Each shape has a TopLeft property, that is a Cell reference.

Hum. Interesting.

This is not a direct association between a shape and a cell, right? It's the cell that the TopLeft of the shape happens to be "over" - for lack of a better term.
 

It is the cell over which the top left corner of the shape resides.

There is also a BottomRight property.

Yes, it is not a DIRECT association, since the Shape's Parent object is the Worksheet.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Thanks for the information. I will try these out. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top