Force use of pasting PictObj/Bitmap only

grady121

Active Member
Joined
May 27, 2005
Messages
383
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,215,326
Messages
6,124,267
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top