Can Someone Tell Me If This Should Work Please

rockyw

Well-known Member
Joined
Dec 26, 2010
Messages
1,196
Office Version
  1. 2010
Platform
  1. Windows
I found this insert macro but I cannot get it to work.

Code:
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
The instructions said...
Column A = imagename (AL-100Y)
Column B = imagepath (c:vonnieimages)
Column C = place to insert image
Image extension can be jpg or gif

I put in column A 01
In column B C:Pictures
I can not get this to work. Can someone tell me what might be wrong? Do I need more in A and B. Thanks
 
Try a "\" at the end of picture path:

In column B C:\Pictures\


Edit: Need another after C:
 
Upvote 0
Thanks for the help, this picture idea is killing me. I have ..
A is 01"\"
B is C:\Pictures\
I see the macro run and change to column C but it does not insert the image. I have a folder in C named Pictures and 5 images named 01 thru 05. Thanks again for the help
 
Upvote 0
tweedle Sorry, I got it to work but the image comes into column A and B, I thought it would come in C? And I thought I could edit from there to add more rows. Thanks
 
Upvote 0
Lets do A1 as just 01

B1 as C:\Pictures\

so you should end up with

C:\Pictures\01.gif
and
C:\Pictures\01.jpg
 
Upvote 0
OH! and if I bring two or more in they stack on top each other. Is there a code that works with pictures? Thanks
 
Upvote 0
NP

to push it over to C
Replace:
Code:
Picture.Left = Picture.TopLeftCell.Left
With :
Code:
Picture.Left = Cells(Row, 3).Left

To control the top use:
Code:
Picture.Top = Cells(Row, 3).Top
 
Last edited:
Upvote 0
do you have an entire directory of pictures you want to import without listing every picture in excel?
 
Upvote 0
That's great! I can make the 3 a 5 and make a new row, and so on. Can I ask one more question? Is there a way to skip a row in between, like for a name? I was asked if I can make a program for all the emplyees, this will make it a LOT faster. Thnaks
 
Upvote 0

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