BeforeShapeDelete 事件 (Visio)Masters.BeforeShapeDelete event (Visio)

在删除形状之前,发生此事件。Occurs before a shape is deleted.


表达式BeforeShapeDelete(形状)expression.BeforeShapeDelete (Shape)

_表达式_一个代表**主控形状** 对象的变量。expression A variable that represents a Masters object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
ShapeShape 必需Required [IVSHAPE][IVSHAPE] 要删除的形状。The shape that is going to be deleted.


如果形状的Type属性是visTypeGroup (2) 或visTypePage (1), 则shape对象可用作BeforeShapeDelete事件的源对象。A Shape object can serve as the source object for the BeforeShapeDelete event if the shape's Type property is visTypeGroup (2) or visTypePage (1).

BeforeSelectionDeleteBeforeShapeDelete 事件的相似之处在于它们都在删除形状之前触发。The BeforeSelectionDelete and BeforeShapeDelete events are similar in that they both fire before shape(s) are deleted. 它们的区别在于,当单个操作删除多个形状时它们的行为方式不同。They differ in how they behave when a single operation deletes several shapes. 假定一个 “剪切” 操作删除三个形状。Suppose a Cut operation deletes three shapes. BeforeShapeDelete 事件触发三次并分别作用于三个对象中的每个对象。The BeforeShapeDelete event fires three times and acts on each of the three objects. BeforeSelectionDelete 事件触发一次,并作用于所选的要删除的三个形状所在的 Selection 对象。The BeforeSelectionDelete event fires once, and it acts on a Selection object in which the three shapes that you want to delete are selected.

如果您使用 Microsoft Visual Basic 或 Visual Basic for Applications (VBA),则此主题中的语法描述的是一种通用而有效的事件处理方法。If you are using Microsoft Visual Basic or Visual Basic for Applications (VBA), the syntax in this topic describes a common, efficient way to handle events.

如果要创建自己的Event对象, 请使用**Add** 或**AddAdvise** 方法。If you want to create your own Event objects, use the Add or AddAdvise method. 若要创建可运行加载项的 Event 对象,请使用 Add 方法,因为它适用于 EventList 集合。To create an Event object that runs an add-on, use the Add method as it applies to the EventList collection. 若要创建可接收通知的 Event 对象,请使用 AddAdvise 方法。To create an Event object that receives notification, use the AddAdvise method. 若要查找要创建的事件的事件代码,请参阅事件代码To find an event code for the event that you want to create, see Event codes.


您可以使用 VBA WithEvents关键字来接收BeforeShapeDelete事件。You can use the VBA WithEvents keyword to sink the BeforeShapeDelete event.

出于性能方面的考虑,Document 对象的事件集不包含 BeforeShapeDelete 事件。For performance considerations, the Document object's event set does not include the BeforeShapeDelete event. 若要接收来自Document对象 (和 VBA 项目中的**ThisDocument** 对象) 的BeforeShapeDelete事件, 必须使用AddAdvise方法。To sink the BeforeShapeDelete event from a Document object (and from the ThisDocument object in a VBA project), you must use the AddAdvise method.

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.