ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell/function manipulation (https://www.excelbanter.com/excel-programming/366006-cell-function-manipulation.html)

mazzarin

Cell/function manipulation
 
Hello again,
Trying to pull pictures based of a value in a cell. They should be
named the same. For example, in cell C2, the value is A123. So this
process should retrieve C:\Images\A123.bmp However, I receive the error
'The specified file wasn't found'. I've played around with it for a
while, and tried using various code I found through searching here but
I cannot get it to work.

Thoughts?

Code below.


Dim s As Shape

With [E2]
Set s = .Parent.Shapes.AddPicture( _
"C:\Images\'" & Range("C2").Value & "'"".bmp", _
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.45, msoTrue
.ScaleWidth 0.48, msoTrue
End With


Trevor Shuttleworth

Cell/function manipulation
 
Try:

Dim s As Shape
With [E2]
Set s = .Parent.Shapes.AddPicture( _
"C:\Images\" & Range("C2").Value & ".bmp", _
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.45, msoTrue
.ScaleWidth 0.48, msoTrue
End With

Regards

Trevor


"mazzarin" wrote in message
oups.com...
Hello again,
Trying to pull pictures based of a value in a cell. They should be
named the same. For example, in cell C2, the value is A123. So this
process should retrieve C:\Images\A123.bmp However, I receive the error
'The specified file wasn't found'. I've played around with it for a
while, and tried using various code I found through searching here but
I cannot get it to work.

Thoughts?

Code below.


Dim s As Shape

With [E2]
Set s = .Parent.Shapes.AddPicture( _
"C:\Images\'" & Range("C2").Value & "'"".bmp", _
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.45, msoTrue
.ScaleWidth 0.48, msoTrue
End With





All times are GMT +1. The time now is 09:54 AM.

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