Call .NET method from within Outlook Macro

Hey all

I would like to do the following: Allow someone to call a method in a VB.NET application from within an Outlook 2007 Macro. Sort of a transfer of control if you will. Is there any way to do that and if so how?

I would then use this method to do everything I have to on the .NET application. The reason I want to do it this way is because of automation purposes and making it easier on the user.

Also if the application is closed, is there a way to open the application and still leave authentication(log in screen) in check and then after that still run the method as per usual?

Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I dont see it as possible. You can not make method calls on EXEs. What you can possibly do is call the exe with command line arguments but it gives you limited functionality.
Corey ScheichDeveloperCommented:
You can do this using .Net Remoting and a com Registered class.

if you com register the ipcClient you can make calls to it from an out of process macro.  This method can also be used to talk across the 32/64bit divide.

the page above has a c# example
Corey ScheichDeveloperCommented:
For example in the macro you could have the following code

Sub main()
Dim client As New RemotingLibrary.client

Dim Frm As New RemotingLibrary.formController

Frm.SetText ("I set the text")

End Sub

with the following .Net code

Once you have registered the client channel you can then create instances of the registered object and the instances are running in the remote process though they look local to the macro.

Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Ipc
Imports System.Runtime.Remoting
Public Class formController
    Private Shared frm As MyApplicationForm
    Sub New()
        If formController.frm Is Nothing Then
            formController.frm = New MyApplicationForm
        End If
    End Sub
    Sub SetText(ByVal Value As String)
        formController.frm.TextBox1.Text = Value
    End Sub
End Class
Public Class RemoteServer
    Public Sub New()
        ChannelServices.RegisterChannel(New IpcChannel("Remote"), False)
        RemotingConfiguration.RegisterWellKnownServiceType(GetType(RemotingLibrary.formController), "MyAppForm", WellKnownObjectMode.Singleton)
    End Sub
End Class
Public Class Client
    Public Sub New()
        ChannelServices.RegisterChannel(New IpcClientChannel, False)
        RemotingConfiguration.RegisterWellKnownClientType(GetType(RemotingLibrary.formController), "ipc://Remote/MyAppForm")
    End Sub
End Class

Open in new window

culminITAuthor Commented:
I have found a solution here:
Also here (forms part of other solution):

Thanks for the help

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.