none
VB.NET and VBA in Outlook RRS feed

  • Question

  • Hi everybody...

    I am writing an add-in for Outlook and I am stuck within the communication between VB.NET and Outlooks' VBA.

    My add-in needs to create a new module in the activeVBProject and write some code in it. I searched Google for an answer, but all I found was how to do this in excel.

    I tried to do the same in Outlook

      Dim olapp As Object
                    Dim olmodule As vbide.vbcomponent
                    Dim olcode As String
                    olapp = CreateObject("Outlook.Application")
                    olapp.vbproject.vbcomponents.add(VBIDE.vbext_ComponentType.vbext_ct_StdModule)
                    olcode = "test"
                    olmodule.codemodule.addfromstring(olcode)

    but outlook does not support the VBIDE.VBComponent.

    Can anybody tell me if it is possible to do something?

    thx in advance

    Monday, July 21, 2014 6:49 AM

Answers

All replies

  • Hi everybody...

    I am writing an add-in for Outlook and I am stuck within the communication between VB.NET and Outlooks' VBA.

    My add-in needs to create a new module in the activeVBProject and write some code in it. I searched Google for an answer, but all I found was how to do this in excel.

    I tried to do the same in Outlook

      Dim olapp As Object
                    Dim olmodule As vbide.vbcomponent
                    Dim olcode As String
                    olapp = CreateObject("Outlook.Application")
                    olapp.vbproject.vbcomponents.add(VBIDE.vbext_ComponentType.vbext_ct_StdModule)
                    olcode = "test"
                    olmodule.codemodule.addfromstring(olcode)

    but outlook does not support the VBIDE.VBComponent.

    Can anybody tell me if it is possible to do something?

    thx in advance

    • Moved by Carl Cai Tuesday, July 22, 2014 6:51 AM (from vb.net)More related
    • Merged by George HuaModerator Monday, July 28, 2014 10:27 AM same question
    Monday, July 21, 2014 6:42 AM
  • Most probably you have a better chance for a up to date solution in the Visual Studio To Office forum

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vsto


    Success
    Cor


    Monday, July 21, 2014 6:46 AM
  • Don't know. Maybe this link or links within this link can assist you or not.

    Automating Outlook from a Visual Basic Application


    La vida loca

    Monday, July 21, 2014 6:53 AM
  • Hello,

    There is no need to create a new instance of the Application class in Outlook. You can use the Application property provided by the VSTO base classes.

     olapp = CreateObject("Outlook.Application")
    

    The Outlook object model doesn't provide the vbproject property for accessing VBA. I'd recommend moving your code to the add-in instead.

    Why do you need to add another VBA module in the add-in?

    Monday, July 21, 2014 8:42 AM
  • it would also be possible to just write the code into the "ThisSession"-module....

    i coded a lot in outlook and it would be very complicated to realize all the code within vb .net.

    thats the reason why i look for a way to just copy the code into a new or an existing outlook vba module.

    Monday, July 21, 2014 8:47 AM
  • Nope. The Outlook object model is the same for all kind of applications. You may find the following pages in the MSDN library helpful:

    Chapter 4: Moving from VBA to VSTO and Visual Basic

    Chapter 12: Migrating VBA Solutions to VSTO

    Feel free to ask if you meet anything on your road.

    Monday, July 21, 2014 9:06 AM
  • Hi fabsch

    As this is really an Outlook question I'm going to move it to the Outlook for Developers forum. You'll find a lot more Outlook specialists there who may have an idea.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, July 21, 2014 2:24 PM
  • Hi everybody...

    I am writing an add-in for Outlook and I am stuck within the communication between VB.NET and Outlooks' VBA.

    My add-in needs to create a new module in the activeVBProject and write some code in it. I searched Google for an answer, but all I found was how to do this in excel.

    I tried to do the same in Outlook

      Dim olapp As Object
                    Dim olmodule As vbide.vbcomponent
                    Dim olcode As String
                    olapp = CreateObject("Outlook.Application")
                    olapp.vbproject.vbcomponents.add(VBIDE.vbext_ComponentType.vbext_ct_StdModule)
                    olcode = "test"
                    olmodule.codemodule.addfromstring(olcode)

    but outlook does not support the VBIDE.VBComponent.

    Can anybody tell me if it is possible to do something?

    thx in advance

    Hi,

    I have helped you move this thread to more related form to get supports.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 22, 2014 6:54 AM
  • thx a lot...

    may i have the link of the thread?

    Tuesday, July 22, 2014 6:58 AM
  • thx a lot...

    may i have the link of the thread?

    Hi,

    It's ok that just focus on this thread.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 22, 2014 7:00 AM
  • See VB.NET and VBA in Outlook . Please don't create duplicates on the forums.
    Tuesday, July 22, 2014 7:14 AM