Visio2000: The VBA Query Events Sample in the DVS Folder of Visio Standard 2000 International English Doesn't Work (258486)



The information in this article applies to:

  • Microsoft Visio 2000 Standard Edition
  • Microsoft Visio 2000 Technical Edition
  • Microsoft Visio 2000 Professional Edition
  • Microsoft Visio 2000 Enterprise Edition

This article was previously published under Q258486

SYMPTOMS

The sample file "VBA Query Events.VSD" does not work as it is described on the Visio drawing that the VBA code is attached to. Rather than asking you to confirm deletion of the currently selected objects, you receive the following message:

Selection is about to be deleted.

You can only click OK. You cannot prevent the deletion.

CAUSE

The Document_QueryCancelSelectionDelete function in the sample file does not reference the QuerySelectionDelete event correctly.

RESOLUTION

To work around this behavior, modify the Document_QueryCancelSelectionDelete function as follows:
  • Instead of referencing QuerySelectionDelete, which returns an integer, reference QueryCancelSelectionDelete, which returns a Boolean value.

  • Return FALSE to allow the operation and TRUE to cancel it, which is the opposite of the sample code.
The Document_QueryCancelSelectionDelete function should appear in the code as follows:
Private Function Document_QueryCancelSelectionDelete(ByVal Selection As IVSelection) As Boolean
Dim msgBoxResult As VbMsgBoxResult
Dim bRetVal As Boolean

'Verify user wants to delete
msgBoxResult = MsgBox("Would you like to cancel the deletion?", _
                        vbYesNo, "QuerySelectionDelete Event")

'Check user answer
Select Case msgBoxResult
    Case vbYes
        bRetVal = True
    Case vbNo
        bRetVal = False
    Case Else
        bRetVal = False
End Select

'return value to allow or cancel deletion
Document_QueryCancelSelectionDelete = bRetVal
End Function
				

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbbug kbdocerr kbdtacode kbpending KB258486