ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Inserting Pictures (https://www.excelbanter.com/excel-discussion-misc-queries/164194-inserting-pictures.html)

DamienO

Inserting Pictures
 
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

JE McGimpsey

Inserting Pictures
 
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


In article ,
DamienO wrote:

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


DamienO

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

"JE McGimpsey" wrote:

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


In article ,
DamienO wrote:

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




All times are GMT +1. The time now is 06:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com