working with images

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
*******************************
 
T

Tom Ogilvy

There is no way to just change the filename unless you use some type of
image control that holds the picture. Using Pictures.Insert puts the image
in as a separate object. Whether it would cause problems or not, I think
you would just need to test it (but I wouldn't expect therer to be a
problem). If you keep your zoom at 100%, I believe it should work. I have
loaded several hundred pictures in succession and haven't had a problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top