Hi all,
In workbook 1, I have a Command button that creates a Picture object from a range of cells.
Range("A3:P29").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
The intention is to paste this "Picture" object into workbook 2 using another Command button, which also re-sizes the Picture image and fits it into a specific print area.
Unfortunately Workbook 2 contains many other Command buttons that copies & paste “Drawing” objects along with text to the Clipboard.
My code at the moment calls the Error Message if only "text" is left on the Clipboard, but if a Drawing object (Shape) is the last thing copied it re-sizes that.
Code:
Sub InsertSCREEN()
Range("C3").Select
On Error GoTo NoImage
ActiveSheet.Paste
Selection.ShapeRange.IncrementTop 1.5
Selection.ShapeRange.IncrementLeft 1.5
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 430.5
Selection.ShapeRange.Width = 794.25
Selection.ShapeRange.Rotation = 0#
Selection.ShapeRange.ScaleWidth 1.9, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 2.46, msoFalse, msoScaleFromTopLeft
Range("A1").Select
Exit SubNoImage:
MsgBox "Copy screen and try again.", vbCritical, " No Image Copied"
End Sub
Obviosly there is no problem if the user carries this out one after the other, but if they are distracted or have to do something else quickly they may overwite the Clipboard.
So if possible, can anyone suggest a code insert that will call the Error Message if the object left on the Clipboard is NOT a "Picture/Bitmap" object, that can be re-positioned and re-sized.
Thanks in advance
In workbook 1, I have a Command button that creates a Picture object from a range of cells.
Range("A3:P29").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
The intention is to paste this "Picture" object into workbook 2 using another Command button, which also re-sizes the Picture image and fits it into a specific print area.
Unfortunately Workbook 2 contains many other Command buttons that copies & paste “Drawing” objects along with text to the Clipboard.
My code at the moment calls the Error Message if only "text" is left on the Clipboard, but if a Drawing object (Shape) is the last thing copied it re-sizes that.
Code:
Sub InsertSCREEN()
Range("C3").Select
On Error GoTo NoImage
ActiveSheet.Paste
Selection.ShapeRange.IncrementTop 1.5
Selection.ShapeRange.IncrementLeft 1.5
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 430.5
Selection.ShapeRange.Width = 794.25
Selection.ShapeRange.Rotation = 0#
Selection.ShapeRange.ScaleWidth 1.9, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 2.46, msoFalse, msoScaleFromTopLeft
Range("A1").Select
Exit SubNoImage:
MsgBox "Copy screen and try again.", vbCritical, " No Image Copied"
End Sub
Obviosly there is no problem if the user carries this out one after the other, but if they are distracted or have to do something else quickly they may overwite the Clipboard.
So if possible, can anyone suggest a code insert that will call the Error Message if the object left on the Clipboard is NOT a "Picture/Bitmap" object, that can be re-positioned and re-sized.
Thanks in advance