LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Insert picture with macro

Hi Esrei

I wrote the code below a while ago and I think it may be of some use
to you. List your picture names in the worksheet (i.e. my
picture.jpg) then when you click on this cell a rectangle with the
picture will show beside that cell.

In the module for the worksheet with your picture names paste the
following code.

Option Explicit

Dim H, V As Integer
Dim I As Integer
Dim MyDoc As Worksheet

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Set MyDoc = ActiveSheet 'Set your worksheet

H = Target.Offset(0, 1).Left 'Get the values for placement
V = Target.Offset(0, 1).Top 'of the picture

I = MyDoc.Shapes.Count 'Count shapes in MyDoc

If I 0 Then 'If any shape exist delete all shapes
MyDoc.Shapes("Comment").Select
Selection.Delete
End If

If Target.Count 1 Then 'Check than only one cell is selected
Exit Sub
End If

If Target.Value = "" Then 'Check cell has a value
Exit Sub
End If

'Load the picture to the shape, 200 = shape width, 100 = shape height
'the file location should be changed to show your picture directory.

MyDoc.Shapes.AddShape(msoShapeRectangle, H, V, 200, 100).Select
Selection.Name = "Comment"
Selection.ShapeRange.Fill.UserPicture "C:\Pics\" & Target.Value

End Sub

Hope it helps you

S



 
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
Insert, position, and resize a picture w/ Macro John Excel Discussion (Misc queries) 1 July 10th 07 07:21 PM
Insert Picture Macro. scottybalotty Excel Programming 0 February 15th 06 10:05 PM
Insert Picture Name Assignment in Macro Frankenroc Excel Programming 6 January 19th 06 06:15 PM
Insert Picture Macro SamDev Excel Programming 5 September 9th 05 07:09 PM
INSERT PICTURE IN MACRO Glenn Excel Programming 1 April 23rd 05 11:49 PM


All times are GMT +1. The time now is 04:13 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"