none
<Application.Run> equivalent for Microsoft Outlook RRS feed

  • Question

  • Hi all,

    Is there an (exel, word, access) <Application.Run> equivalent in outlook? i.e. Can I call vba code by name?

    Thanks,

    Yiannis

    Thursday, August 18, 2011 1:39 PM

Answers

  • This works but is not at all supported, so it may not continue working.
     
    Create your code as Public Subs and put the code in the ThisOutlookSession class module. You can then use Outlook.Application.MySub() to call your sub named MySub. Of course change that for the correct name.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Yiannis Spyridakis" <=?utf-8?B?WWlhbm5pcyBTcHlyaWRha2lz?=> wrote in message news:d455ba89-b2d4-4dda-8b13-54e941f7f71a...

    Hi all,

    Is there an (exel, word, access) <Application.Run> equivalent in outlook? i.e. Can I call vba code by name?

    Thanks,

    Yiannis


    Ken Slovak MVP - Outlook
    Thursday, August 18, 2011 2:03 PM
    Moderator

All replies

  • This works but is not at all supported, so it may not continue working.
     
    Create your code as Public Subs and put the code in the ThisOutlookSession class module. You can then use Outlook.Application.MySub() to call your sub named MySub. Of course change that for the correct name.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Yiannis Spyridakis" <=?utf-8?B?WWlhbm5pcyBTcHlyaWRha2lz?=> wrote in message news:d455ba89-b2d4-4dda-8b13-54e941f7f71a...

    Hi all,

    Is there an (exel, word, access) <Application.Run> equivalent in outlook? i.e. Can I call vba code by name?

    Thanks,

    Yiannis


    Ken Slovak MVP - Outlook
    Thursday, August 18, 2011 2:03 PM
    Moderator
  • Thanks Ken,

    This is interesting. It appears that the <ThisOutLookSession> class is of type application.

     

    In the immediate window:

    ?typename(ThisOutLookSession)
    Application

    I have little experience in coding outlook, but I supsect that the reason something similar to <Application.Run> isn't exposed is that there is only support for a single VBA project in an outlook session, is that correct?

    Thanks,

    Yiannis

    Thursday, August 18, 2011 3:57 PM
  • There is only 1 possible VBA project for Outlook, and within that project Application is an intrinsic referring to the Outlook.Application object. Outlook VBA is actually implemented as an Outlook COM addin.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Yiannis Spyridakis" <=?utf-8?B?WWlhbm5pcyBTcHlyaWRha2lz?=> wrote in message news:480aaad3-0f2c-426c-a7dd-e526a55be8bb...

    Thanks Ken,

    This is interesting. It appears that the <ThisOutLookSession> class is of type application.

     

    In the immediate window:

    ?typename(ThisOutLookSession)
    Application

    I have little experience in coding outlook, but I supsect that the reason something similar to <Application.Run> isn't exposed is that there is only support for a single VBA project in an outlook session, is that correct?

    Thanks,

    Yiannis


    Ken Slovak MVP - Outlook
    Thursday, August 18, 2011 5:47 PM
    Moderator
  • Thanks Ken,

    "VBA Functors" (http://www.codeproject.com/KB/office/VBAFunctors.aspx) will still work, but I was hoping to be able to run VBA code by getting my hands on the Application object - I guess ThisOutLookSession is my best bet.

    Still how do the RibbonX VBA callbacks work, I wonder...

    Yiannis

    Thursday, August 18, 2011 9:15 PM
  • The ribbon, custom task panes and business logic in form regions can only be handled in COM addins in Outlook. Not at all in VBA code.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Yiannis Spyridakis" <=?utf-8?B?WWlhbm5pcyBTcHlyaWRha2lz?=> wrote in message news:6782f123-42fe-4659-b23c-6d50b2a786bd...

    Thanks Ken,

    "VBA Functors" (http://www.codeproject.com/KB/office/VBAFunctors.aspx) will still work, but I was hoping to be able to run VBA code by getting my hands on the Application object - I guess ThisOutLookSession is my best bet.

    Still how do the RibbonX VBA callbacks work, I wonder...

    Yiannis


    Ken Slovak MVP - Outlook
    Friday, August 19, 2011 8:41 PM
    Moderator
  • Ah, OK that makes sense then. Thanks for all the help Ken.

     

    Regards,

    Yiannis

    Saturday, August 20, 2011 7:39 PM