Skip to main content
New Participant
August 4, 2008
Question

how to add EventListener in VB.NET

  • August 4, 2008
  • 4 replies
  • 2458 views
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
This topic has been closed for replies.

4 replies

_AhWa_Author
New Participant
August 5, 2008
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.
Known Participant
August 5, 2008
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
_AhWa_Author
New Participant
August 5, 2008
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,
Known Participant
August 4, 2008
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