Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Insert picture with macro

I have red the reference articles and questions on displaying a picture when
changing a reference in a cell. I do not want to save the picture in the
worksheet but rather save the path in a cell to be a lookup. Is this
possible? I am designing a orderform.
Thank you

Esrei
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 182
Default Insert picture with macro

hi,

that's all possible, you can use:
Assume that range("A1") text is correct filename like "C:\picture.bmp"
sub insertpic()
sheets(1).pictures.insert range("A1")
end sub

--
Regards,

Halim



"Esrei" wrote:

I have red the reference articles and questions on displaying a picture when
changing a reference in a cell. I do not want to save the picture in the
worksheet but rather save the path in a cell to be a lookup. Is this
possible? I am designing a orderform.
Thank you

Esrei

  #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



Reply
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 01:49 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"