A Pictures Puzzle

E

eBob.com

I have some thumbnails (all .jpgs) which I am trying to insert into rows in
a spreadsheet. All are reported by Windows Explorer to have a Width of 60
pixels and a Height of 100 pixels. Using various programs all look to be
exactly or nearly exactly the same size. But when I insert these pictures
into a spreadsheet only one of them is the size I think it should be - i.e.
the size all of these pictures appear to be when rendered by various
programs - all of the others are shrunk to about 1/5th to 1/4th the size
they appear to be when rendered by various programs.. After a lot of
experimentation I think that the problem might relate to "resolution". The
one picture which ends up the "right" size when inserted is 72x72dpi. Most
of the other pictures are 300x300, one is 180x180. Note that all of the
shrunk pictures appear to be the same size - i.e. the 180x180 picture
appears to be the same size as the 300x300 pictures.

First question: does it sound like I am on the right track? If so, second
question: what's the best solution. I know I can size the pictures, but I
am creating this spreadsheet programmatically using VB.Net. So, first
problem, it looks like I have to figure out how Excel names inserted
pictures. (Using record macro the first line of the macro is
ActiveSheet.Shapes("Picture 7").Select. Ok, I was probably playing with the
7th or maybe 8th inserted picture. BUT ... will future versions of Excel
name pictures in EXACTLY the same way?) But using VB.Net I also have the
option of invoking some program which can change resolution. Maybe, there's
a lot of mystery to all of this pictures stuff. And I sure don't know
off-hand of any programs which can adjust resolution.

But, if I do go with changing the size in Excel, and I expect I will, which
is better - to change the "size" height and width, or the "scale" height and
width. Both seem to achieve the desired result. But maybe one method
retains more fidelity than the other. I don't see any difference but I know
that my eyes are not the best.

Thanks for reading all this. I'll be grateful for any advice and/or
sympathy. Bob
 
J

Joel

The naming convention for pictures STINKs in Excel. The name property cannot
be changed. Excel assigns a name to the picture when it is inserted.
Haven't found a way to change the name.

I ussually find the name by using the following loop

for each myshape in worksheets.shapes

msgbox(myshape.name)

next myshape
 
J

Jim Cone

"Shapes" is a collection. If you first determine the number of shapes on a
sheet... N = ActiveSheet.Shapes.Count, then the next picture you add
will be ActiveSheet.Shapes(N + 1).
I doubt if users will take kindly to your program changing the screen
resolution for them You could however, determine the existing screen
resolution and size the picture accordingly.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"eBob.com" <[email protected]>
wrote in message
I have some thumbnails (all .jpgs) which I am trying to insert into rows in
a spreadsheet. All are reported by Windows Explorer to have a Width of 60
pixels and a Height of 100 pixels. Using various programs all look to be
exactly or nearly exactly the same size. But when I insert these pictures
into a spreadsheet only one of them is the size I think it should be - i.e.
the size all of these pictures appear to be when rendered by various
programs - all of the others are shrunk to about 1/5th to 1/4th the size
they appear to be when rendered by various programs.. After a lot of
experimentation I think that the problem might relate to "resolution". The
one picture which ends up the "right" size when inserted is 72x72dpi. Most
of the other pictures are 300x300, one is 180x180. Note that all of the
shrunk pictures appear to be the same size - i.e. the 180x180 picture
appears to be the same size as the 300x300 pictures.

First question: does it sound like I am on the right track? If so, second
question: what's the best solution. I know I can size the pictures, but I
am creating this spreadsheet programmatically using VB.Net. So, first
problem, it looks like I have to figure out how Excel names inserted
pictures. (Using record macro the first line of the macro is
ActiveSheet.Shapes("Picture 7").Select. Ok, I was probably playing with the
7th or maybe 8th inserted picture. BUT ... will future versions of Excel
name pictures in EXACTLY the same way?) But using VB.Net I also have the
option of invoking some program which can change resolution. Maybe, there's
a lot of mystery to all of this pictures stuff. And I sure don't know
off-hand of any programs which can adjust resolution.

But, if I do go with changing the size in Excel, and I expect I will, which
is better - to change the "size" height and width, or the "scale" height and
width. Both seem to achieve the desired result. But maybe one method
retains more fidelity than the other. I don't see any difference but I know
that my eyes are not the best.
Thanks for reading all this. I'll be grateful for any advice and/or
sympathy. Bob
 
P

Peter T

As Jim says, the object counter and name suffix increments each time a shape
is added to the sheet. However if shapes are deleted the counter is not
decremented or reset to the lowest non existent object number.

The only way to reset the counter is to delete all shapes and save / close /
reopen the workbook.

To return the name of the last added shape, or in your case last inserted
picture, the name would be -

with activesheet.shapes
if .count then
sName = .item(.count).name
end if
end with

(above assumes ZOrder has not been changed since the last shape was added)

Concerning size, the Insert method does not accurately set the size to the
original picture size. It sounds like you already know your image sizes so
simply resize width & height after the insert. Your image sizes are in
pixels so bear in mind 'Shapes' are sized in Points. For most systems 0.75
pixels = 1 point, but best to verify. You may then want to add say 1.5
points for the border.

If you don't know your original image sizes, generally WxH can be read from
file or after first loading to a Worksheet Image control.

Regards,
Peter T
 

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