can we shrink images to fit?

  • Thread starter Thread starter J_J
  • Start date Start date
J

J_J

Hi,
Can we automatically adjust the sizes of images that we import as *.gif etc
files into excel so that all images displayed on an excel sheet (or within
excel cells) are the same?. How?. VBA solution is also accepted.
Regards
J_J
 
Thanks Anne,
But this ain't the case...
I need to import images from different *.gif files on my HDD and want to
display them say in column H2:H50
I want to make sure that whatever the original sizes of the images are on
the files, I want them to appear with same sizes on column H2:H50. This is
especially a problem for me, because of bigger images within the bunch...
Sincerely
J_J
 
J_J said:
Hi,
Can we automatically adjust the sizes of images that we import as *.gif etc
files into excel so that all images displayed on an excel sheet (or within
excel cells) are the same?. How?. VBA solution is also accepted.

You can acheive the obvious scaling of the displayed images, but it will
quickly get out of hand with huge filesizes of full resolution images in
Excel.

You would be better off using an image handling application to batch
resize copies of the originals down to the required size first and then
importing them. eg Irfanview(free) would do it.

Loading a 5Mpixel image to show a 160x120 thumbnail is very inefficient...

Regards,
Martin Brown
 
Hi. I've not done this, so I'll just throw this out as an option to
explore. Under Tools | Options | General | Pictures Tab.., there is an
option for "Screen Size:".
Perhaps try an experiment and save a copy of your work as a web page, using
File | Save as web page...
Perhaps if you import this page later into Excel, maybe they'll be the size
you need.
I'm not sure if that option just displays the picture at the selected size,
or will reduce all pictures to the desired size as the file is saved.
If you try this, I'd be curious how it worked. :>) HTH.

--
Dana DeLouis
Win XP & Office 2003


Hi,
Can we automatically adjust the sizes of images that we import as *.gif etc
files into excel so that all images displayed on an excel sheet (or within
excel cells) are the same?. How?. VBA solution is also accepted.
Regards
J_J
 
Every image has a Heigth and Width property which can be set. This doesn't
maintain the aspect ratio, however. Post back with more information if this
doesn't help you.
 
Hi Tom,

Say I have ten *.gif images on my HDD with varous sizes (height:between
20-50 and width:between 50-100).
I want to display them on Sheet1 in cells D2 to D12 with a fixed height and
width-say 20x20).
How can I setup a macro to do that?.
Thanks to: Martin and Dana too

J_J
 
Sub Demo3()
Dim pic As Object
Dim r As Range
Dim i As Long
For i = 1 To 10
Set pic = ActiveSheet.Pictures.Insert( _
"C:\My Pictures\Sample" & i & ".jpg")
Set r = Range("D1").Offset(i, 0)
pic.Top = r.Top
pic.Left = r.Left
pic.Width = r.Width
pic.Height = r.Height
Next
End Sub
 
Thanks for the example Tom,
Forgive me but where have you set your code to let the "r" variable hold the
"20" value actually?
(Sorry if my doesnt look noble :)
Regards
J_J
 
Dear Sir,
I am Sorry for my typing mistakes in my previous post. But here is my
question again

Thank you for the example Tom,
Forgive me but maybe I am not keen enough to see. In your example code,
Where have you set the "r" variable to hold the "20" value actually?. Or
have you programmed such that cell D1 dimension will be the used for all
*.jpg images through D1:D10?
Regards
J_J
 
r is a reference to a range.

This was sample code to show you the components you can use to build your
required solution.

If you are putting 11 pictures in column D in cells D2 to D12, then
logically, each picture would be the height of the cell. Likewise, it would
make sense to make them as wide as the cell. So you can make the cells as
high and as wide as necessary to meet your 20 x 20 criteria.

then my code matches the picture to exactly fit the cell.

If you don't want to do that, then do

pic.Top = r.Top
pic.Left = r.Left
pic.Width = 20
pic.Height = 20
 
Thank you Tom,
I'll try your code and get back to here if face any other problem.
You were most helpful, and patient with me.:)
As always.
Best wishes
J_J
 

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

Back
Top