我有一个脚本,通过形状的纸张循环,抓住图像属性为picHeight
和picWidth
变量工作:错误处理程序不是“438运行时错误”
ws.Shapes(myImg.ID).Select
With Selection
killer = IsError(.ShapeRange.Height)
If IsError(.ShapeRange.Height) = True Then
GoTo badShape
End If
PicHeight = .ShapeRange.Height
PicWidth = .ShapeRange.Width
End With
有时候形状不是图片(在图纸上也有图表和文本框),VBA会一直抛出“438错误”(对象不支持此属性或方法),即使添加了on error resume next
以及上面的错误处理程序。当选择对象不具有.shaperange.height
或shaperange.width
属性时会出现此问题。
看来VBA根本无法将代码交给错误处理程序,因为选择中没有选定的成员。
尝试[this](http://stackoverflow.com/questions/3440735/vba-error-handling-not-working-in-excel/3440789#3440789),看看是否有助于错误处理。 –
之前我已经碰到过,不幸的是这次不是这种情况。 –