convert Outlook VBA code to add-in

I have some working VBA code for an Outlook macro. What if any procedures are available to convert that to an add-in to Outlook with the minimum amount of re-programing. Are there conversion tools that would help?
lineonecorpAsked:
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.

TomasPCommented:
Convert VBA to VB. Fairly straightforward. Create an Outlook add-in using the SDK. Place your logic in the shell app.
You will have to address distribution and security of course
0

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
lineonecorpAuthor Commented:
Thanks for the quick response. When you say 'Place your logic in the shell app.' is that a cut-and-paste operation?
0
TomasPCommented:
Yes, but depending on your logic you will want to leverage the logic required by the plugin logic especially around communication. You will have to split and tune your code for the new environment.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

lineonecorpAuthor Commented:
It doesn't sound so cut-and-paste.  Can you give me a few examples of the kind of  'logic' that I might employ that would require a lot of re-working?
0
TomasPCommented:
Not seeing what your VBA does makes that difficult. If most of your logic is internal to your program and doesn't require a lot of calls to built in VBA functions then you are pretty well set.
Create an Outlook plugin using Visual Studio and the SDK and you will see the stub functions that should be populated to interact with Outlook as a plugin.

0
lineonecorpAuthor Commented:
Code follows. Perhaps you could point out whether it would be cut-and-paste or not and if not what is it in the code that renders it not cut-and-paste.
++++++++++++

Dim WithEvents colInsp As Outlook.Inspectors
Private Sub Application_Startup()
    Set colInsp = Application.Inspectors
End Sub
Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
    Dim msg As Outlook.MailItem
    Dim mymsg As String
    Dim myResult As Integer
    Dim count As Integer
 
    On Error Resume Next
    If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
        Set msg = Inspector.CurrentItem
       
        If msg.Size = 0 Then
 
            If msg.Recipients.count > 1 Then
                mymsg = "Do you really want to reply to all original recipients?"
                myResult = MsgBox(mymsg, vbYesNo, "Flame Protector")
                If myResult = vbNo Then
                       
                    StripExternal msg
 
                End If
            End If
        End If
        Set msg = Nothing
    End If
End Sub
 
Sub StripExternal(olkMsg As Outlook.MailItem)
    Const INTERNAL_DOMAIN = "@itchieh.com"
    Const INTERNAL_X400 = "/O=FIRST ORGANIZATION"
    Dim olkRcp As Outlook.Recipient, intIndex As Integer
    olkMsg.Recipients.ResolveAll
    For intIndex = olkMsg.Recipients.count To 1 Step -1
        Set olkRcp = olkMsg.Recipients.Item(intIndex)
        Select Case olkRcp.AddressEntry.AddressEntryUserType
            Case olSmtpAddressEntry
                If InStr(1, LCase(olkRcp.Address), INTERNAL_DOMAIN, vbTextCompare) = 0 Then
                    olkMsg.Recipients.Item(intIndex).Delete
                End If
            Case olExchangeUserAddressEntry
                If InStr(1, olkRcp.Address, INTERNAL_X400, vbTextCompare) = 0 Then
                    olkMsg.Recipients.Item(intIndex).Delete
                End If
            Case olExchangeDistributionListAddressEntry, olOutlookDistributionListAddressEntry
            Case Else
                MsgBox "The message contains an unusual address type that cannot be processed.", vbExclamation + vbOKOnly, "Strip External"
        End Select
    Next
End Sub
Sub DisplayX400()
    Dim olkMsg As Outlook.MailItem, olkRcp As Outlook.Recipient
    Set olkMsg = Application.ActiveInspector.CurrentItem
    olkMsg.Recipients.ResolveAll
    For Each olkRcp In olkMsg.Recipients
        MsgBox olkRcp.Address
    Next
    Set olkMsg = Nothing
    Set olkRcp = Nothing
End Sub

0
lineonecorpAuthor Commented:
Still responding?
0
TomasPCommented:
you will have to look for the assemblies corresponding to Outlook objects you use.
MailItem, Recepient. The object structures may be different so you will likely have to tune your code a bit to use the new object interfaces. It looks straightforward and a bit of looking at the SDK will be helpful to show you which assemblies you will need. There are also some VBA to .Net converts out there that will take care of most of the grunt work.
0
lineonecorpAuthor Commented:
Expert did not answer question asked.  I think the Expert was trying so I am leaving the points. However, I received nothing of value from this Exchange.
0
TomasPCommented:
Some parts you will be able to cut and paste but my point is that the VBA objects will not map exactly to the .NET objects. There are porting tools some of which are free that will do some of the dirty work but you will still need to bring your code in line with the interfaces/objects offered by .net
0
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
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.