View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Repost: Speed of inserting pictures and Excel memory

Hi Greg,

I don't think AddPicture vs Insert.Picture will make any difference as
regards the main issue that the first time to add/insert is slower. Also as
you say, the first time the picture is ever drawn it can flicker, perhaps
only noticeable with very large image files. Anyway it's two separate delays
that one way or another are not going to be avoided, at least I don't think
so.

If interested I can send a stripped down version of a few things from my xls
image browser.
Insert Next or Previous image in current folder
optionally change size, fade in rate
or
Insert all images from current folder
optionally change size, gap width

change current folder with GetOpenFileName

It does not disable screenupdating nor preload images yet I think reasonably
smooth. What might be of interest to you is all insert & resizing is done
outside the visible range before moving into it.

Regards,
Peter T
email: pmbthornton gmail com

"Greg Wilson" wrote in message
...
Thanks Peter. I was using a For Each loop to delete the photos for the
scrolling feature. I like your batch delete method better.

I did a brief experiment with the Shapes.AddPicture method and found it

did
not behave the same. Initializing the photos had no affect, but this was

only
a very brief experiment.

If I go the route of using Shapes.AddPicture then (apparently) I'll need

to
add functionality that allows the user to specify the height/width ratio.

In
my case, all the photos for a given survey will be the same size but the

size
may change between surveys (i.e. cameras or camera settings may change). I
keep wondering if I'm missing something because it seems everyone should

be
bitching about this problem: If you don't know the correct proportionality
for the photos, then they will be distorted if you specify incorrect

values
for the width and height arguments. As you may have noticed in my code, I
currently insert the photos using Pictures.Insert and test for the height

and
width and obtain the proportionality this way. I then change the size to

suit.

Regards,
Greg

"Peter T" wrote:

Hi Greg,

I have some routines that add large numbers of pictures from file,

resized
and placed to suit. Like you, I find the first time in a session of

Excel I
add a picture is significantly slower than subsequently. Strangely,

normally
(but not always) it's only slow for the first inserted picture assuming

all
in the same folder, Unlike you I don't find resizing & placing is

relevant
as regards time.

I don't find any reason to use an InitializePhotos routine such as

yours.
The "extra" time is same if inserted & deleted to a dummy sheet or as &

when
required. Instead I add direct to the active sheet. I don't disable
screenupdating but I ensure I scroll well away both from the active cell
(where the picture will first be inserted) and less importantly away

from
where any will be moved after resizing. Then I scroll or "Goto" back.

If I know all the original picture H/W proportions are identical,

instead of
insert pictures, sizing & placing, I use the AddPicture method and do

all in
one go.

FWIW, to delete ALL pictures on a sheet simply:
..Pictures.Delete

Regards,
Peter T