4 Replies Latest reply on Aug 5, 2008 1:44 AM by (AhWa)

    how to add EventListener in VB.NET

      I want to use Pure VB.NET Code to handle the InDesign events through the ComObject.

      I found the EventListener.Add function. However, I don't know how to use it.

      Anyone can tell me? thx
        • 1. Re: how to add EventListener in VB.NET
          Level 1
          Hi AhWa,

          Have you tried the scripting documentation? It's at the InDesign scripting home page, which is listed at the top of this forum. The chapter on working with events should answer your question.

          You can add your event listener using VB.NET, but you'll probably have to call a VBScript or JavaScript on disk as the event handler.

          Thanks,

          Ole
          • 2. Re: how to add EventListener in VB.NET
            Level 1
            Hi Ole,

            I had read the scripting document. and try to port the VBScript codes to be VB.Net Codes. However, EventListener.Add() required a Object
            type handler. So that I have no idea about what should I pass such type for this parameter.

            I wounder, Is it possible that a pure VB.Net coded Application driving the Indesign DOM Object with event handler?

            Really don't want to deal with the C++.

            Thanks,
            • 3. Re: how to add EventListener in VB.NET
              Level 1
              Hi AhWa,

              Here's the template for the EventListeners.Add method:

              Function Add(EventType As String, Handler, [Captures As Boolean = False]) As EventListener

              The qualifying event strings for the EventType parameter are shown in the documentation. The Handler parameter is a reference to a file--a VBScript file on disk. The event will pass parameters to this file when it triggers.

              As I said, I don't think you can have a "pure" VB.NET application that works with events.

              You're welcome to try the C++ API (which doesn't work with events in the same way at all), but I think you'd be better off using VBScripts for the event handlers.

              Thanks,

              Ole
              • 4. Re: how to add EventListener in VB.NET
                Level 1
                Thank you Ole,

                Finally, I give out the "pure" VB.NET approach and move to pure C++ approach. The Scripting API did not provide sufficient event for my project.