Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Insert Picture using Macro & Validation list

Hi,

I have an excel file and in Cell "L21" I have a Validation list that
contains Picture names I want to see if I could place a Macro that
every time I select a picture name from the Validation list macro
would look into a folder (C:\Temp\Pix\) that contains all the pictures
(some .jpg, .gif. etc.) and insert it in cell "L10" and resize the
picture to Height 42 by keeping the Aspect Ratio. If no pictures were
found insert default picture called "NO Pic"

Thanks,
Marc
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Insert Picture using Macro & Validation list

You code would then only run from a single PC that has all the picture.
Another mthod is to put all the pictures into a workbook. Resize them
manually and put them ontop of each other. You can make one visiable and
make all the others invisible. then when you select the validation list move
the picurte you want to the top of the other picture and make it visible and
the others invisible.

"marc747" wrote:

Hi,

I have an excel file and in Cell "L21" I have a Validation list that
contains Picture names I want to see if I could place a Macro that
every time I select a picture name from the Validation list macro
would look into a folder (C:\Temp\Pix\) that contains all the pictures
(some .jpg, .gif. etc.) and insert it in cell "L10" and resize the
picture to Height 42 by keeping the Aspect Ratio. If no pictures were
found insert default picture called "NO Pic"

Thanks,
Marc
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Insert Picture using Macro & Validation list

It's OK ti run on single PC, Is there any other way besides loading
all on a workbook.

Thanks,
Marc



On Nov 12, 1:36*pm, Joel wrote:
You code would then only run from a single PC that has all the picture. *
Another mthod is to put all the pictures into a workbook. *Resize them
manually and put them ontop of each other. *You can make one visiable and
make all the others invisible. *then when you select the validation list move
the picurte you want to the top of the other picture and make it visible and
the others invisible.



"marc747" wrote:
Hi,


I have an excel file and in Cell "L21" I have a Validation list that
contains Picture names I want to see if I could place a Macro that
every time I select a picture name from the Validation list macro
would look into a folder (C:\Temp\Pix\) that contains all the pictures
(some .jpg, .gif. etc.) and insert it in cell "L10" and resize the
picture to Height 42 by keeping the Aspect Ratio. If no pictures were
found insert default picture called "NO Pic"


Thanks,
Marc
.- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Insert Picture using Macro & Validation list

Marc,

You could use the worksheet change event. Copy this code, right-click the
sheet tab, select "View Code" and insert the code into the window that
appears. I have assumed that the file name in cell L21 includes the file
extension.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myScale As Double
If Target.Address < "$L$21" Then Exit Sub

'Select the cell where the picture is placed
Application.EnableEvents = False
On Error Resume Next
ActiveSheet.Shapes("KnownPictureName").Delete
On Error GoTo 0

Range("L10").Select
'Insert the picture
On Error GoTo NoPic
ActiveSheet.Pictures.Insert("C:\Temp\Pix\" & Range("L21").Value).Select
GoTo GotPic
NoPic:
ActiveSheet.Pictures.Insert("C:\Temp\Pix\No Pic.jpg").Select
GotPic:
'scale the picture to the width of the column
myScale = 42 / Selection.ShapeRange.Height
Selection.Name = "KnownPictureName"
Selection.ShapeRange.ScaleWidth myScale, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight myScale, msoFalse, msoScaleFromTopLeft
Range("L22").Select

Application.EnableEvents = True
End Sub


"marc747" wrote in message
...
Hi,

I have an excel file and in Cell "L21" I have a Validation list that
contains Picture names I want to see if I could place a Macro that
every time I select a picture name from the Validation list macro
would look into a folder (C:\Temp\Pix\) that contains all the pictures
(some .jpg, .gif. etc.) and insert it in cell "L10" and resize the
picture to Height 42 by keeping the Aspect Ratio. If no pictures were
found insert default picture called "NO Pic"

Thanks,
Marc


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Insert Picture using Macro & Validation list

Hi,

Thanks, but the file name does not include the file extension. Can we
add a line so that it can look for the most common extensions.

Marc



On Nov 12, 4:48*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Marc,

You could use the worksheet change event. Copy this code, right-click the
sheet tab, select "View Code" and insert the code into the window that
appears. *I have assumed that the file name in cell L21 includes the file
extension.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myScale As Double
If Target.Address < "$L$21" Then Exit Sub

'Select the cell where the picture is placed
Application.EnableEvents = False
On Error Resume Next
ActiveSheet.Shapes("KnownPictureName").Delete
On Error GoTo 0

Range("L10").Select
'Insert the picture
On Error GoTo NoPic
ActiveSheet.Pictures.Insert("C:\Temp\Pix\" & Range("L21").Value).Select
GoTo GotPic
NoPic:
ActiveSheet.Pictures.Insert("C:\Temp\Pix\No Pic.jpg").Select
GotPic:
'scale the picture to the width of the column
myScale = 42 / Selection.ShapeRange.Height
Selection.Name = "KnownPictureName"
Selection.ShapeRange.ScaleWidth myScale, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight myScale, msoFalse, msoScaleFromTopLeft
Range("L22").Select

Application.EnableEvents = True
End Sub

"marc747" wrote in message

...



Hi,


I have an excel file and in Cell "L21" I have a Validation list that
contains Picture names I want to see if I could place a Macro that
every time I select a picture name from the Validation list macro
would look into a folder (C:\Temp\Pix\) that contains all the pictures
(some .jpg, .gif. etc.) and insert it in cell "L10" and resize the
picture to Height 42 by keeping the Aspect Ratio. If no pictures were
found insert default picture called "NO Pic"


Thanks,
Marc- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Insert Picture using Macro & Validation list

Couldn't you just add the extension to the filename in L21

filename.jpg or .bmp or whatever.


Gord Dibben MS Excel MVP

On Fri, 13 Nov 2009 12:55:39 -0800 (PST), marc747
wrote:

Hi,

Thanks, but the file name does not include the file extension. Can we
add a line so that it can look for the most common extensions.

Marc



On Nov 12, 4:48*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Marc,

You could use the worksheet change event. Copy this code, right-click the
sheet tab, select "View Code" and insert the code into the window that
appears. *I have assumed that the file name in cell L21 includes the file
extension.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myScale As Double
If Target.Address < "$L$21" Then Exit Sub

'Select the cell where the picture is placed
Application.EnableEvents = False
On Error Resume Next
ActiveSheet.Shapes("KnownPictureName").Delete
On Error GoTo 0

Range("L10").Select
'Insert the picture
On Error GoTo NoPic
ActiveSheet.Pictures.Insert("C:\Temp\Pix\" & Range("L21").Value).Select
GoTo GotPic
NoPic:
ActiveSheet.Pictures.Insert("C:\Temp\Pix\No Pic.jpg").Select
GotPic:
'scale the picture to the width of the column
myScale = 42 / Selection.ShapeRange.Height
Selection.Name = "KnownPictureName"
Selection.ShapeRange.ScaleWidth myScale, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight myScale, msoFalse, msoScaleFromTopLeft
Range("L22").Select

Application.EnableEvents = True
End Sub

"marc747" wrote in message

...



Hi,


I have an excel file and in Cell "L21" I have a Validation list that
contains Picture names I want to see if I could place a Macro that
every time I select a picture name from the Validation list macro
would look into a folder (C:\Temp\Pix\) that contains all the pictures
(some .jpg, .gif. etc.) and insert it in cell "L10" and resize the
picture to Height 42 by keeping the Aspect Ratio. If no pictures were
found insert default picture called "NO Pic"


Thanks,
Marc- Hide quoted text -


- Show quoted text -


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 picture using Macro.. [email protected] Excel Programming 15 June 21st 08 12:48 AM
Insert picture with macro Esrei Excel Programming 2 August 21st 07 02:20 PM
Insert Picture Macro. scottybalotty Excel Programming 0 February 15th 06 10:05 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 07:10 AM.

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"