Error MessageBox Required

grady121

Active Member
Joined
May 27, 2005
Messages
383
Office Version
  1. 2016
Platform
  1. Windows
I should be able to do this but can't seem to get my head around it.

I can bypass the error, but what I'm looking for is a simple OK MessageBox to appear when an error occurs in my code. i.e. when a Screendump has not been copied to the Clipboard yet.

The error occurs on line "Selection.ShapeRange.IncrementTop 1.5" - if there's no 'Shape' to work with?
My code at the moment reads:

Sub InsertClipboard()

Range("C3").Select
ActiveSheet.Paste
On Error GoTo 0
Exit Sub
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

End Sub

I'm just looking for a simple message to say "No Image available" across the bar.
With "Copy to Clipboard and try again" in the body.

Any help appreciated.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
In a throwaway copy of your wb, try:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> InsertClipboard()<br><br>    Range("C3").Select<br>    ActiveSheet.Paste<br>    <br>    <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> BailOut<br>    <br>    Selection.ShapeRange.IncrementTop 1.5<br>    Selection.ShapeRange.IncrementLeft 1.5<br>    Selection.ShapeRange.LockAspectRatio = msoFalse<br>    Selection.ShapeRange.Height = 430.5<br>    Selection.ShapeRange.Width = 794.25<br>    Selection.ShapeRange.Rotation = 0#<br>    Selection.ShapeRange.ScaleWidth 1.9, msoFalse, msoScaleFromTopLeft<br>    Selection.ShapeRange.ScaleHeight 2.46, msoFalse, msoScaleFromTopLeft<br>    <br>    <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0<br>    <br>    Range("A1").Select<br><SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>BailOut:<br>    MsgBox "Copy to Clip Board and try again.", vbCritical, "Tile bar text"<br>    <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

Hope this helps,

Mark
 
Upvote 0
Many thanks GTO

I couldn't see the wood from the trees !!!

Just what I needed.
 
Upvote 0

Forum statistics

Threads
1,215,944
Messages
6,127,835
Members
449,411
Latest member
adunn_23

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