BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu


Started by mmulvenna, January 25, 2009, 12:40:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


I am probably being really dense here and i suspect i am missing someting pretty simple but....I have the following code in my application. It is copied from the SDK but the one event I added does not even compile.
I get a runtime error   ...exception occured" when it gets to this line  Set vsoScopeEnteredEvent = vsoDocumentEvents.AddAdvise( _
     visEvtCodeEnterScope, mEventSink, "", "Enter Scope...")

I want to trap when an item is added to a group so i thought i could use the scope entered event to do this.The above line is the only one I added. Are there additional parameters that i need to provide to visevtcodeenterscope

This code is in a class module.
Implements Visio.IVisEventProc

Thanks in advance for any help

'Declare visEvtAdd as a 2-byte value
'to avoid a run-time overflow error
Private Const visEvtAdd% = &H8000

Private Function IVisEventProc_VisEventProc( _
        ByVal nEventCode As Integer, _
        ByVal pSourceObj As Object, _
        ByVal nEventID As Long, _
        ByVal nEventSeqNum As Long, _
        ByVal pSubjectObj As Object, _
        ByVal vMoreInfo As Variant) As Variant

    Dim strMessage As String

    'Find out which event fired
    Select Case nEventCode
        Case visEvtCodeDocSave
            strMessage = "DocumentSaved (" & nEventCode & ")"
        Case (visEvtPage + visEvtAdd)
            strMessage = "PageAdded (" & nEventCode & ")"
        Case visEvtCodeShapeDelete
            strMessage = "ShapesDeleted(" & nEventCode & ")"
         Case visEvtCodeEnterScope
         strMessage = "enterscope(" & nEventCode & ")"
        Case Else
            strMessage = "Other (" & nEventCode & ")"
    End Select

    'Display the event name and the event code
    MsgBox strMessage

End Function

This code is in a module.
Option Explicit

Private mEventSink As clsEventSink

Dim vsoDocumentEvents As Visio.EventList
Dim vsoDocumentSavedEvent As Visio.Event
Dim vsoPageAddedEvent As Visio.Event
Dim vsoShapesDeletedEvent As Visio.Event
Dim vsoScopeEnteredEvent As Visio.Event

'Declare visEvtAdd as a 2-byte value
'to avoid a run-time overflow error
Private Const visEvtAdd% = &H8000

Public Sub CreateEventObjects()
    'Create an instance of the clsEventSink class
    'to pass to the AddAdvise method.
    Set mEventSink = New clsEventSink

    'Get the EventList collection of the active document.
    Set vsoDocumentEvents = ActiveDocument.EventList

    'Add Event objects that will send notifications.
    'Add an Event object for the DocumentSaved event.
    Set vsoDocumentSavedEvent = vsoDocumentEvents.AddAdvise( _
     visEvtCodeDocSave, mEventSink, "", "Document saved...")

    'Add an Event object for the PageAdded event.
    Set vsoPageAddedEvent = vsoDocumentEvents.AddAdvise( _
     visEvtAdd + visEvtPage, mEventSink, "", "Page added...")
     'Add an Event object for the ShapesDeleted event.
    Set vsoShapesDeletedEvent = vsoDocumentEvents.AddAdvise( _
     visEvtCodeShapeDelete, mEventSink, "", "Shapes deleted...")
   Set vsoScopeEnteredEvent = vsoDocumentEvents.AddAdvise( _
     visEvtCodeEnterScope, mEventSink, "", "Enter Scope...")
End Sub

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 142 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1054KB.
Tokens: post-login.
Cache hits: 14: 0.00123s for 26,767 bytes (show)
Cache misses: 3: (show)
Queries used: 15.

[Show Queries]