Help on Pictures


Posted by James Wiltshire on October 04, 2000 3:19 AM

Hi, I`m writing an excel macro that automatically loads a set of pictures into different parts of an excel worksheet. The problem is all the pictures are different sizes, at the moment i`m using the stretch function to resize them. Is there a way to import them into the worksheet with the same sizes, for example importing a picture into a text box in word.

Posted by Ben O. on October 04, 2000 8:21 AM

You should be able to use VBA to change the height and width of a picture after you insert it. Here's an example:

ActiveSheet.Pictures.Insert ("C:\WINDOWS\Desktop\logo.gif").Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 257.25

You can make it Selection.ShapeRange.Width = x if the width of the pictures is what you want uniform. If you want both the height and the width to be uniform, you can put both lines in, but you'll have unlock the aspect ratio.

I hope this helps.

-Ben


automatically loads a set of pictures into different parts of an excel worksheet. The problem is all the pictures are different sizes, at the moment i`m using the stretch function to resize them. Is there a way to import them into the worksheet with the same sizes, for example importing a picture into a text box in word.



Posted by james wiltshire on October 05, 2000 9:32 AM

Ben. Thanks very much, works a treat. James