Macro For Images

ghailey

New Member
Joined
Dec 4, 2008
Messages
5
Hello,

i am currently trying to adapt Rikrak's formula below so that it will point to a certain folder on a hard drive. Can anyone advise how to do this please?

Currently i can only get this formula to add images when they are in the location of C:\



Try this, it will insert specified images in column C.
Assuming:
Column A = imagename (AL-100Y)
Column B = imagepath (c:vonnieimages)
Column C = place to insert image
Image extension can be jpg or gif



Sub InsertPictures()
Dim row As Long
Dim picPath As String
Dim Picture As Object

row = 1

On Error Resume Next

While Cells(row, 1) <> ""
Cells(row, 3).Select

' just guess what type of picture it is: .jpg or .gif
picPath = Cells(row, 2) & Cells(row, 1) & ".gif"
ActiveSheet.Pictures.Insert(picPath).Select
picPath = Cells(row, 2) & Cells(row, 1) & ".jpg"
ActiveSheet.Pictures.Insert(picPath).Select

Set Picture = Selection
'set cell height to picture size
Picture.Top = Picture.TopLeftCell.Top
Picture.Left = Picture.TopLeftCell.Left
Picture.TopLeftCell.EntireRow.RowHeight = Picture.Height

row = row + 1

Wend
End Sub

</PRE>
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Looks like you need to place the file path for the images in the respective cells in column B. Were you looking to do this via a dialog box?
 
Upvote 0
Hi excelR8R,

thanks for the reply. yes i am aware that the file path needs to be in column B. if i have C:\ i can get the image to load using the macro above as long as i have an image with the correct name saved in C:\
if i change it to C:\my documents and have the correctly named photo the macro runs but it will not load the images.
it seems to me i need an extra part written in the macro to point it to the correct folder so it can then get the relevant images.

no i did not want a dialog box.

i am trying to create a pricelist that will load each photo to match the relevant file name. So far it works but all photos must be in C:\

hope this makes sense
regards Gian.
 
Upvote 0

Forum statistics

Threads
1,215,855
Messages
6,127,349
Members
449,381
Latest member
Aircuart

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top