Inserting Pictures

G

Guest

is it possible to set an area in an excel sheet to receive a pasted picture ?
I want to set an area that will accept a picture from the clipbord but I
want to have a defined size so that the same picture size comes out every
time and I can have text etc on the page in the same place every time
 
J

JE McGimpsey

There's no built-in way to do this. You could easily use a macro:

Public Sub SetPicture()
Const cnMAXHEIGHT As Long = 250
Const cnMAXWIDTH As Long = 200
Dim rTopLeft As Range
Dim dScale As Double
If TypeOf Selection Is Picture Then
With Selection
Set rTopLeft = .Parent.Range("F2")
.Top = rTopLeft.Top
.Left = rTopLeft.Left
dScale = Application.Min( _
cnMAXWIDTH / .Width, cnMAXHEIGHT / .Height)
With .ShapeRange
.ScaleWidth dScale, False, msoScaleFromTopLeft
.ScaleHeight dScale, False, msoScaleFromTopLeft
End With
End With
Else
MsgBox "Please select a picture"
End If
End Sub
 
G

Guest

Thanks for that. I'll give it a go later

JE McGimpsey said:
There's no built-in way to do this. You could easily use a macro:

Public Sub SetPicture()
Const cnMAXHEIGHT As Long = 250
Const cnMAXWIDTH As Long = 200
Dim rTopLeft As Range
Dim dScale As Double
If TypeOf Selection Is Picture Then
With Selection
Set rTopLeft = .Parent.Range("F2")
.Top = rTopLeft.Top
.Left = rTopLeft.Left
dScale = Application.Min( _
cnMAXWIDTH / .Width, cnMAXHEIGHT / .Height)
With .ShapeRange
.ScaleWidth dScale, False, msoScaleFromTopLeft
.ScaleHeight dScale, False, msoScaleFromTopLeft
End With
End With
Else
MsgBox "Please select a picture"
End If
End Sub
 

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