LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Insert Pictures using Macros

Hi I have a Marco that inserts pictures in excel, I need to make a few
changes but I am having difficulty.
This macro is looking into a cell that has the picture file location
and it is inserting the picture right below that cell. But what I need
to change is, I need to be able to insert the picture to different
cell (example: the cell that has the location on the file is "B4" and
I want to insert the picture in cell "B9")

Below is the macro that I use. I would greatly appreciate for your
help, Thank You.






Sub add_pictures()


Const PictureHeight = 120

Application.ScreenUpdating = False

'delete pictures
For Each shp In ActiveSheet.Shapes
If shp.Type = msoPicture Then
shp.Delete
End If
Next shp


LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Rows(5).RowHeight = PictureHeight


For Each cell In Range("B4:IV4")
If cell < "" Then
cell.Offset(1, 0).ClearContents
On Error GoTo NoPict 'new line
Set pict = ActiveSheet.Pictures. _
Insert(cell.Value)
If cell.Offset(1, 0).Value < "Picture not Available" Then
'new line
pict.ShapeRange.LockAspectRatio = msoTrue
pict.ShapeRange.Height = PictureHeight
pict.Top = cell.Offset(1, 0).Top
pict.Left = cell.Offset(1, 0).Left
End If
End If 'new line
Next cell
Exit Sub 'new line


NoPict: cell.Offset(1, 0).Value = "Picture not Available" 'new line
Resume Next 'new line


End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't insert pictures laurie New Users to Excel 2 April 5th 23 01:21 PM
Insert pictures AZU Excel Discussion (Misc queries) 5 March 6th 09 05:28 PM
insert pictures [email protected] Excel Programming 5 October 29th 07 10:23 AM
Insert pictures dc Excel Programming 2 June 5th 07 06:43 AM
Macros associated with pictures Eric Excel Discussion (Misc queries) 2 April 29th 05 10:15 PM


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"