View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Finny388 Finny388 is offline
external usenet poster
 
Posts: 36
Default Should be simple: Lookup a picture from a folder based on a cell value changing

On Apr 19, 9:31 am, Finny388 wrote:
On Apr 19, 8:29 am, Finny388 wrote:



On Apr 19, 7:56 am, Finny388 wrote:


On Apr 18, 11:53 pm, "NickHK" wrote:


One way is to put an image control on your WS, sized to the correct
dimensions.
Set its .PictureSizeMode to 3 - fmPictureSizeModeZoom.


Then in that WS_Change event:


If not intersect(target,<YourRange) Is nothing then
Image1.Picture= LoadPicture(Target.Text)
'...etc


You should add error handling in case the graphic does not exist/can't load.


NickHK


"Finny388" wrote in message


roups.com...


I saw
http://www.mcgimpsey.com/excel/lookuppics.html
but where did he keep his pictures?


I just want to show apicturebases on a cell value that is equal to
the name of the jpg in afolder.


When the cell (A1) changes its value, alookupshow the jpg with the
same text of the value.


Change A1 to "Picture5" and C:\Pictures\Picture5.jpg shows up in C1.


bonus: thepicturesized to the size of the C1 cell without losing its
aspect ratio


Thanks!


Thanks Nick,
But how do I do thelookupto the windowsfoldercontaining the jpg's?
What event would be the trigger?
TIA


btw, I am talking about a couple hundred pictures, mcgimpsey mentions
that for a large amount, a db solution is better. yikes.


I'd like to trigger by selected value in a combo box.
My code for pulling the pic is so far this: i just need to
trigger it

Sub ImageLookup()
Dim MyPic As IPictureDisp
On Error Resume Next
Set MyPic = LoadPicture("I:\Customers\Quadro Catalogue & Pictures
\SAP Pictures\" & Range("a6").Value & ".jpg")
PicPath = "I:\Customers\Quadro Catalogue & Pictures\SAP Pictures\"
& Range("a6").Value & ".jpg"
H = MyPic.Height
W = MyPic.Width
R1 = W / H
Cells(2, 4).Select
Set pic = ActiveSheet.Pictures.Insert(PickPath)
pic.Height = Cells(2, 4).Height
pic.Width = Cells(2, 4).Height * R1
End Sub


I put it in Worksheet_Change event handler according to John
Walkenbach's VBA book.
It only triggers when "d5" is changed through in an edit.
Not by pointing to another cell that changes.
and not by pointing combobox to it (which is what i want to do)

is there a combobox change event? any ideas on what can be the trigger?