Getting a pictures height, width before setting it in Shapes.AddPicture

C

Chris

I'm inserting several images into a worksheet however these images are
rather large.

Therefore rather than doing

Worksheets(1).Range("A1").Select()
Worksheets(1).Range("A1").Pictures.Insert(picture_path)

I have

Worksheets(1).Shapes.AddPicture picture_path, _
LinkToFile:=True, _
SaveWithDocument:=False, _
Left:=Range("A1").Left, _
Top:=Range("A1").Top, _
Width:=PROBLEM HERE, _
Height:=PROBLEM HERE

The problem is, I will be cropping these images and I need to know the
width's and height's of the images so when I use the AddPicture method
it sizes them correctly. How I've overcome this is combine both
methods for with the following code

Worksheets(1).Range("A1").Select
Worksheets(1).Range("A1").Pictures.Insert(picture_path).Select
tmpWidth = Selection.ShapeRange.Width
tmpHeight = Selection.ShapeRange.Height
Selection.Delete
Worksheets(1).Shapes.AddPicture picture_path, _
LinkToFile:=True, _
SaveWithDocument:=False, _
Left:=Range("A1").Left, _
Top:=Range("A1").Top, _
Width:=tmpWidth, _
Height:=tmpHeight

The key property that I can find in AddPictures, but not in
Pictures.Insert is the SaveWithDocument property. These images are
around 17 MB and I would be inserting around 30-40 of them.

Is there a way to access this and set it to False if I just do
Worksheets(1).Range("A1").Select()
Worksheets(1).Range("A1").Pictures.Insert(picture_path)
 

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