Using Automation withevents

BastikiBastiki Member Posts: 11
Hi there,

it might be possible that anyone else already had this problem.
I want to do some automation with Outlook.
CREATE(olApp);
olFolder := olApp.GetNamespace('MAPI').GetDefaultFolder(5);
olExplorer := olApp.Explorers.Add(olFolder,0);

The olExplorer-Variable is set up with "WITHEVENTS = YES". But when trying to compile this piece of code an error occurs saying that it's not permitted to assign something to a variable that is withevents-activated.

Now the question is, is there any way to do this thought? I really need the SELECTIONCHANGE-Event from the Explorer-Object.

Thanx in advance for any suggestion.

Comments

  • garakgarak Member Posts: 3,263
    Try to use instead of the event property:

    'Microsoft Outlook 12.0 Object Library'.ExplorerEvents
    Do you make it right, it works too!
  • BastikiBastiki Member Posts: 11
    Thanks a lot for this. but I think I forgot to say, that I already had this idea. But there are two things that made me think that this would be no solution :(

    1. Accodring to Microsoft, the ExplorerEvents are intended for internal use
    2. How would I assign the ExplorerEvents to react on the Events of my Explorer-Object?

    The worst thing is, that it's not possible to "CREATE" the Explorer-Object. It MUST be assigned :(
  • peterzpeterz Member Posts: 5
    Any solution to this problem? I have the same problem (when sending email with Office 11 automation)
  • 2mas2mas Member Posts: 7
    Hello Guys,

    I found already existing, but i guess forgotten topic about this strange limitation for automations:
    IF WithEvents property is set to true, then no assignment to variable can be done.
    Problem: my variable has to be initiated from other one's function so assignment is necessary here...
    But also for me this variable without events makes no sense at all... So maybe someone discovered workarounds how to
    manage both things for that variable ? Automation is 'Microsoft Speech Object Library'.SpSharedRecognizer
  • piktazpiktaz Member Posts: 9
    Hi, 2mas,

    write your own comvisible class with implemented object 'Microsoft Speech Object Library'. Add “load” method to your class to put that object from outside. Catch the object’s events within the class and bypass them to Navision with your custom event. On Navision create automation with events, load variable and wait for events.

    Good luck!
Sign In or Register to comment.