S
Stuart
In the following few lines of code, I am attempting to show an image of a
file listed in column "A". The following does work however I don't think I
am going about it the correct way. You will note from my code that I am
deleting an image then creating a new image on every occasion, would it not
be better to just change the file reference of the image, and if so how
would I do that?
In creating so many images, am I likely to run into problems, ?
ofD & ofR are the position of the cell!
*********************************************
If Right(ActiveCell.Value, 4) = ".jpg" Then
On Error Resume Next
ActiveSheet.Shapes("PicX").Delete
On Error GoTo 0
fName = "C:\myfiles\alps2003\" & ActiveCell.Value
ActiveSheet.Pictures.Insert(fName).Select
With Selection
.Name = "PicX"
.ShapeRange.Top = ofD + 7
.ShapeRange.Left = ofR + 10
If .Width >= .Height Then
Ls = .Width
Else
Ls = .Height
End If
If Ls > 325 Then
Cs = 325 / Ls
Else
Cs = 1
End If
.ShapeRange.ScaleWidth Cs, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight Cs, msoFalse, msoScaleFromTopLeft
End With
Application.StatusBar = Selection.Width
End If
*******************************
file listed in column "A". The following does work however I don't think I
am going about it the correct way. You will note from my code that I am
deleting an image then creating a new image on every occasion, would it not
be better to just change the file reference of the image, and if so how
would I do that?
In creating so many images, am I likely to run into problems, ?
ofD & ofR are the position of the cell!
*********************************************
If Right(ActiveCell.Value, 4) = ".jpg" Then
On Error Resume Next
ActiveSheet.Shapes("PicX").Delete
On Error GoTo 0
fName = "C:\myfiles\alps2003\" & ActiveCell.Value
ActiveSheet.Pictures.Insert(fName).Select
With Selection
.Name = "PicX"
.ShapeRange.Top = ofD + 7
.ShapeRange.Left = ofR + 10
If .Width >= .Height Then
Ls = .Width
Else
Ls = .Height
End If
If Ls > 325 Then
Cs = 325 / Ls
Else
Cs = 1
End If
.ShapeRange.ScaleWidth Cs, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight Cs, msoFalse, msoScaleFromTopLeft
End With
Application.StatusBar = Selection.Width
End If
*******************************