none
Macro to create another macro on the same machine programatically in outlook RRS feed

  • General discussion

  • Hello all,

    I was wondering if anyone can guide me what/how to learn to make/design custom applications for MS office users to create simple macros for MS Office applications using other than the default way to make it,

    I can make simple macros in office applications like outlook, word, access etc. but,

    what actually I want to make/design is, a custom MS office ( or say outlook) application/program  by that, end user can  create a macro for eg: a forwarding macro and it's "To" , "Cc" and "Bcc" fields can be updated accordingly by the end user but all the coding will be done by the custom application not by user. also tool bars customization may also done by the custom application itself.

    this for the users who don't have enough knowledge in coding/scripting..

    I am not sure my words are in quite order to understand. i will try my level best in case further clarification needed.

    thanks for the support/advise

    kind regards

    shas


    Tuesday, March 20, 2018 7:50 AM

All replies

  • Hello Shas,

    VBA macros are not designed for distributing solutions on multiple machines. Instead, you may consider creating a VSTO based add-in which can be installed on users machines by using installers. See Walkthrough: Creating Your First VSTO Add-In for Outlook to get started quickly.

    Also you may find the following articles helpful:

    Deploying an Office Solution by Using ClickOnce

    Deploying an Office Solution by Using Windows Installer


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, March 20, 2018 9:04 AM
  • Hi Eugene

    thank you very much for your reply. I appreciate it. I definitely spent more time to learn VSTO based add-in and its distribution.

    but there is another area in my above question remained unnoticeable, I believe.

    is it possible to create a macro which can be used to create/insert another macro/sub procedure in VBA?

    like this

    suppose, an outlook vba form with fields like "macroName, To, CC and BCC"

    when user load this form and update these fields, a new macro (sub procedure) will be created like below

    Sub macroName()
    Dim objMsg As MailItem
    Dim emilTo As Outlook.Recipient
    Dim emilCC As Outlook.Recipient
    Dim emailBCC As Outlook.Recipient
    Set objItem = Application.ActiveInspector.CurrentItem
    Set objMsg = objItem.Forward
    Set emilTo = objMsg.Recipients.Add("to.com")
    Set emilCC = objMsg.Recipients.Add("cc.com")
    Set emilbcc = objMsg.Recipients.Add("bcc.com")
    emailTo.Type = olTo
    emailcc.Type = olCC
    emailbco.Type = olBCC
    emailTo.Resolve
    emailcc.Resolve
    emailBCC.Resolve
    objMsg.Display
    End Sub

    so if I create let's say a main/standard vba userform (a forwarding macro in above case) to be used by an end user who probably unknown to vba codlings can create a number forwarding macros with different recipients. further if these new macros can be assigned to customized button programmatically, it would be wonderful.

    I hope this query is apart from just distribute a macro to multiple machines even with VSTO based add-ins.

    regards

    Shas

    Tuesday, March 20, 2018 10:21 AM
  • Shas,

    is it possible to create a macro which can be used to create/insert another macro/sub procedure in VBA?

    Theoretically, it is possible. But you need to run that VBA macro sub on the same machine.

    You can find more information about the VBA macros distribution process in the To distribute Microsoft Outlook VBA code to other users article. 


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, March 20, 2018 2:03 PM
  • Thanks again Eugene for your help

    > Theoretically, it is possible. But you need to run that VBA macro sub on the same machine.

    I've been trying to find more information for such a macro that create another macro on the same machine. but not much luck

    I am trying to create such macro ( macro that creates another macro in the same machine programmatically) in outlook

    could you please share some information in this regard.

    regards

    Shas


    Wednesday, March 21, 2018 8:17 AM
  • I believed I found an answer for the above that it is not quite hard to accomplish in outlook. but some of the other Office applications, like Excel, do allow access to the Visual Basic Editor (VBE) programmaticly so that VBA code can modify / add other VBA modules and code.  But that is not allowed in Outlook, most likely for security reasons.

    courtesy to Mr. Bill Prew

    regards

    Shas

    Thursday, March 22, 2018 8:01 AM