ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to display pictures (https://www.excelbanter.com/excel-programming/405565-macro-display-pictures.html)

captsamm(remove)@comcast.net

Macro to display pictures
 
I am trying to set up a macro that will display a picture depending on the
value in cell G2. Here is the macro, it does not work...any ideas??


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 04-02-2008 by Capt. W. D. Sammons
'

'
Range("H3").Select
if(g2=1.0,ActiveSheet.Pictures.Insert("C:\Document s and
Settings\Sammonsw\Desktop\GenAware\1.1 EXPLOSIVES.jpg").Select, _
if(g2=2.1,ActiveSheet.Pictures.Insert("C:\Document s and
Settings\Sammonsw\Desktop\GenAware\2.1 n FLAM GAS.jpg").select,"X"))
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 144#
Selection.ShapeRange.Width = 147#
Selection.ShapeRange.Rotation = 0#
Range("H12").Select
End Sub


If there is an easier way I would love to know, I have about 16 different
pictures that I want to be able to display

Thanks
Capt Samm

Gord Dibben

Macro to display pictures
 
Have a look at a these couple of solutions.

Note: in both cases the jpgs must be stored on the same worksheet you are
calling from.

To have a picture show up when you select an item from a DV list or type in a
name see JE MCGimpsey's site.

http://www.mcgimpsey.com/excel/lookuppics.html

As written John's code allows for only one picture to be displayed.

Got to Debra Dalgeish's site for a sample workbook from Bernie Dietrick for
adding pictures to selections.

Alows for more than one picture to be displayed.

http://www.contextures.on.ca/excelfiles.html#DataVal

DV0049 - ClipArt Selection


Gord Dibben MS Excel MVP

On Mon, 4 Feb 2008 12:26:00 -0800,
m wrote:

I am trying to set up a macro that will display a picture depending on the
value in cell G2. Here is the macro, it does not work...any ideas??


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 04-02-2008 by Capt. W. D. Sammons
'

'
Range("H3").Select
if(g2=1.0,ActiveSheet.Pictures.Insert("C:\Document s and
Settings\Sammonsw\Desktop\GenAware\1.1 EXPLOSIVES.jpg").Select, _
if(g2=2.1,ActiveSheet.Pictures.Insert("C:\Document s and
Settings\Sammonsw\Desktop\GenAware\2.1 n FLAM GAS.jpg").select,"X"))
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 144#
Selection.ShapeRange.Width = 147#
Selection.ShapeRange.Rotation = 0#
Range("H12").Select
End Sub


If there is an easier way I would love to know, I have about 16 different
pictures that I want to be able to display

Thanks
Capt Samm



Ron Coderre

Macro to display pictures
 
The ShowFilePicsDemo, at the below link, demonstrates how to insert
picture files (bmp, gif, jpg, etc) directly from a network or web folder
into an Excel sheet by selecting an item from a cell data
validation drop-down list.

http://www.contextures.com/excelfiles.html#CH0003

Is that something you can work with?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)


"
m wrote in message
...
I am trying to set up a macro that will display a picture depending on the
value in cell G2. Here is the macro, it does not work...any ideas??


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 04-02-2008 by Capt. W. D. Sammons
'

'
Range("H3").Select
if(g2=1.0,ActiveSheet.Pictures.Insert("C:\Document s and
Settings\Sammonsw\Desktop\GenAware\1.1 EXPLOSIVES.jpg").Select, _
if(g2=2.1,ActiveSheet.Pictures.Insert("C:\Document s and
Settings\Sammonsw\Desktop\GenAware\2.1 n FLAM GAS.jpg").select,"X"))
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 144#
Selection.ShapeRange.Width = 147#
Selection.ShapeRange.Rotation = 0#
Range("H12").Select
End Sub


If there is an easier way I would love to know, I have about 16 different
pictures that I want to be able to display

Thanks
Capt Samm






All times are GMT +1. The time now is 02:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com