Consulting

Results 1 to 2 of 2

Thread: Using WithEvents

  1. #1
    VBAX Newbie
    Joined
    Nov 2017
    Posts
    1
    Location

    Using WithEvents

    Hi all. Here’s the situation:

    I’m using Outlook 2016 and am trying to allow users to edit any email they open.

    To do this, I need to use WithEvents to trap the open email event. This requires creating a Class module, as a regular module won’t allow this. However, a class must be instantiated. To do this I need to run some code. To get this code to run, it’ll have to be triggered when an event occurs.
    But I cannot trap events unless I am able to instantiate Withevents. Which I cannot do unless I can run code to do so. Which I cannot do unless I can trap an event …

    All code I’ve found relating to this simple puts the Withevents declaration at the top of the module. That obviously won’t work.

    (Macros are enabled; in the regular module in the let dropdown the only option is “General”, no “Application events” choice)

    It seems to be one of those “It’s so obvious” things, like how to use a keyboard. But to me it isn’t.
    What am I missing? Thanks.

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Application events are in ThisOutlookSession.
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •