AnsweredAssumed Answered

How to set up Events for a DxDesigner Application

Question asked by joerg.schmidt on Jun 23, 2010
Latest reply on Jun 24, 2010 by joerg.schmidt

Hello!

 

I like to set up a event-handler for a DxDesigner application. But the following code doesn't work and the Dxdesigner crashes during the execution.

It seems that the a Dxdesigner application object has no Active Document?

And the ValidateServer function, which is not shown in my sample code, doesn't work either.

Why do I need the to call this function?

 

My final goal is to set up a function for the Application_ActivateView() - event.

Maybe someone can give me some hint(s)?

 

Thanks Joerg

 

OptionExplicit

' Add any type libraries to be used.
Scripting.AddTypeLibrary("Viewdraw.Application")

' Get the Application object
Dim dxdesignerAppObj
Set dxdesignerAppObj = Application

' Get the active document
Dim dxdesignerDocObj
Set dxdesignerDocObj = dxdesignerAppObj.ActiveDocument

 

' License the document

' ValidateServer(dxdesignerDocObj)

 

' Attach events from the document object.
Call Scripting.AttachEvents(dxdesignerDocObj, "dxdesignerDocObj")

' Set the Scripting.DontExit property to 
' true to keep the script running.
Scripting.DontExit = True

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Event handlers
' PreClose event handler
Function dxdesignerDocObj_OnPreClose()
    Dim ansEnum
    ansEnum = MsgBox("Close this document?", vbYesNo)
    If ansEnum = vbYesThen
        dxdesignerDocObj_OnPreClose = True
    Else
        dxdesignerDocObj_OnPreClose = False
    EndIf
EndFunction

Outcomes