Supress error message

  • Thread starter Thread starter anonymous
  • Start date Start date
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?
 
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:
 
Back
Top