Supress error message

A

anonymous

I have written the following code to center an object in a slide

Sub CenterBoth()
On Error GoTo CenterBothMsg
If IsNull(ActiveWindow.Selection.ShapeRange) Then
MsgBox "yup"
Exit Sub
End If
With ActiveWindow.Selection.ShapeRange
.Align msoAlignMiddles, True
.IncrementTop 105 / 2
.Align msoAlignCenters, True
.IncrementLeft 0
End With
CenterBothMsg:
MsgBox "Please Select A Picture To Center"
On Error GoTo 0
End Sub


Despite the on error statement in no picture is selected I still get
the following message


Run-time error '-2147188160 (80048240)':
Selection (unknown member) : Invalid request. Nothing appropriate is
currently selected.


Is there a way to supress this message and create a more user friendly
message?
 
D

David M. Marcovitz

It works for me without any odd error messages. However, you need to get
rid of the last On Error line, and you need an extra Exit Sub before the
error message. However, even without doing those things, it works as
expected for me.
--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/

(e-mail address removed) wrote in 4ax.com:
 

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