Package Outlook VBA Macro with Custom Button on ribbon










1















I have a VBA Macro on outlook that allows me to forward an email as an attachment to different email addresses.I have customised my outlook ribbon and created a button that is linked to this macro. How would i go by packaging this item (Macro and Ribbon Button) so i can give it to other users to install on their machines?



Thanks,










share|improve this question


























    1















    I have a VBA Macro on outlook that allows me to forward an email as an attachment to different email addresses.I have customised my outlook ribbon and created a button that is linked to this macro. How would i go by packaging this item (Macro and Ribbon Button) so i can give it to other users to install on their machines?



    Thanks,










    share|improve this question
























      1












      1








      1








      I have a VBA Macro on outlook that allows me to forward an email as an attachment to different email addresses.I have customised my outlook ribbon and created a button that is linked to this macro. How would i go by packaging this item (Macro and Ribbon Button) so i can give it to other users to install on their machines?



      Thanks,










      share|improve this question














      I have a VBA Macro on outlook that allows me to forward an email as an attachment to different email addresses.I have customised my outlook ribbon and created a button that is linked to this macro. How would i go by packaging this item (Macro and Ribbon Button) so i can give it to other users to install on their machines?



      Thanks,







      vba outlook office365 outlook-addin outlook-vba






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 19 '18 at 9:31









      WillWill

      64




      64






















          3 Answers
          3






          active

          oldest

          votes


















          1














          I think you could do it programatically. I have a process for sharing my Excel macros/ribbon, and you could try modifying it for Outlook. I'd be curious as to whether it works the same, since I'd like to eventually share my outlook macros as well. All the user has to do is run a batch file. There are a couple of components:



          1. Create a folder in a shared directory, where you can store your personal macros and ribbon.


          2. Copy over your macros from your local folder. For Excel, I copied over my personal excel file where I store my macros, out of C:UsersusernameAppDataRoamingMicrosoftExcelXLSTART. For Outlook, I assume you'd use the VbaProject.OPM file in C:UsersusernameAppDataRoamingMicrosoftOutlook.


          3. Copy over your UI file (ribbon) from your local folder: C:UsersusernameAppDataLocalMicrosoftOffice. The Excel ribbon is called Excel.officeUI, and I assume the Outlook ribbon is the file called olkexplorer.officeUI.



          4. Create your batch file, which will Copy the macros and UI out of the shared directory and on to the user's local drive. It will then call a VBS file which will slightly modify the UI file, replacing occurrences of your username with the user's username. I'm new to batch files and not sure how to insert comments into the code, but you should modify the first path (use the above path where the Outlook OPM file is stored), as well as the name of the macro file and the UI file (VbaProject.OPM and olkexplorer.officeUI).



             Echo off
            cls
            Echo Please ensure that Excel(Outlook) is closed before continuing.
            pause
            cls

            cd YourSharedDirectory
            copy PERSONAL.XLSB c:users%USERNAME%AppDataRoamingMicrosoftExcelXLSTART*.* /y
            cls

            cd YourSharedDirectory
            copy Excel.officeUI C:Users%USERNAME%AppDataLocalMicrosoftOffice*.* /y
            cls

            @echo off
            wscript "findReplaceUserNameinUI.vbs"



          5. Create a VBS file (which you run at the end of the batch file) to find YOUR username in the UI file and replace it with the username of the person downloading the macros, since it won't work on their computer otherwise.



            Const ForReading = 1
            Const ForWriting = 2

            'get username
            username= CreateObject("WScript.Network").UserName

            'change this to the local location for outlook UI
            uiPath = "C:Users" & username & "AppDataLocalMicrosoftOfficeExcel.officeUI"

            'open the UI file in notepad, find & replace with new username
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set objFile = objFSO.OpenTextFile(uiPath, ForReading)
            strText = objFile.ReadAll
            objFile.Close
            strNewText = Replace(strText, "your user name", username)
            Set objFile = objFSO.OpenTextFile(uiPath, ForWriting)
            objFile.WriteLine strNewText
            objFile.close

            msgbox "Completed!"






          share|improve this answer






























            0














            Outlook macro aren't made to be disitributed such as in Excel. You should build an add-in in .NET Framework using Office tools.



            Here's an introduction : https://docs.microsoft.com/en-us/outlook/add-ins/quick-start?tabs=visual-studio



            If you still want to export your macro, there are some workaround :



            Solution 1



            You can export modules as .bas, .cls, frx, and .frm files.Other users will have to reverse the process by importing them.



            With this method no user will lose any code.



            BUT



            When importing the ThisOutlookSession module, it will be renamed ThisOutlookSession1. You'll have to copy the code from here and paste it in ThisOutlookSession or it won't run.



            Solution 2



            If the users don't have any macro project in their Outlook, you can copy (assuming there is only this macro on your Outlook) the VBAProject.OTM that you can find in %AppData%MicrosoftOutlook and overwrite the user's one with it.



            The last method is the one I used when I had to share a macro. But if I knew it would be such a ****** I would have use VB.NET immediately. There are other solutions but I never experimented them.






            share|improve this answer























            • Hi Thanks for that. The only issue is that i had to create the button on the ribbon myself and then link the macro to it. Is there a way i would implement this into the code so that it would add the button to the ribbon when i distribute to the users.

              – Will
              Jun 19 '18 at 12:50











            • I'm currently doing this, I'll let you know if I find a solution.

              – Jérémy Gamba
              Jun 22 '18 at 6:52











            • Look at Roi-Kyi Bryant's answer on this post : stackoverflow.com/questions/8850836/… You can load a custom ribbon when opening your workbook. The disadvantage of this method is that you'll lost any previous customizations on your ribbon.

              – Jérémy Gamba
              Jun 22 '18 at 9:06


















            0














            VBA macros are not designed for distributing solutions on other/multiple machines. Moreover, VBA macros doesn't allow to customize the Fluent UI (aka Ribbon UI) programmatically. You need to develop a COM based add-in for these reasons. That is for they were invented! See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.



            You can read more about the Fluent UI (aka Ribbon UI) in the following series of articles:



            • Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

            • Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

            • Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

            VSTO provides two main ways for creating a custom ribbon UI:



            • Walkthrough: Create a custom tab by using the Ribbon Designer

            • Walkthrough: Create a custom tab by using Ribbon XML

            In case you still want share your VBA macro see To distribute Microsoft Outlook VBA code to other users for possible solutions.






            share|improve this answer






















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50924994%2fpackage-outlook-vba-macro-with-custom-button-on-ribbon%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              I think you could do it programatically. I have a process for sharing my Excel macros/ribbon, and you could try modifying it for Outlook. I'd be curious as to whether it works the same, since I'd like to eventually share my outlook macros as well. All the user has to do is run a batch file. There are a couple of components:



              1. Create a folder in a shared directory, where you can store your personal macros and ribbon.


              2. Copy over your macros from your local folder. For Excel, I copied over my personal excel file where I store my macros, out of C:UsersusernameAppDataRoamingMicrosoftExcelXLSTART. For Outlook, I assume you'd use the VbaProject.OPM file in C:UsersusernameAppDataRoamingMicrosoftOutlook.


              3. Copy over your UI file (ribbon) from your local folder: C:UsersusernameAppDataLocalMicrosoftOffice. The Excel ribbon is called Excel.officeUI, and I assume the Outlook ribbon is the file called olkexplorer.officeUI.



              4. Create your batch file, which will Copy the macros and UI out of the shared directory and on to the user's local drive. It will then call a VBS file which will slightly modify the UI file, replacing occurrences of your username with the user's username. I'm new to batch files and not sure how to insert comments into the code, but you should modify the first path (use the above path where the Outlook OPM file is stored), as well as the name of the macro file and the UI file (VbaProject.OPM and olkexplorer.officeUI).



                 Echo off
                cls
                Echo Please ensure that Excel(Outlook) is closed before continuing.
                pause
                cls

                cd YourSharedDirectory
                copy PERSONAL.XLSB c:users%USERNAME%AppDataRoamingMicrosoftExcelXLSTART*.* /y
                cls

                cd YourSharedDirectory
                copy Excel.officeUI C:Users%USERNAME%AppDataLocalMicrosoftOffice*.* /y
                cls

                @echo off
                wscript "findReplaceUserNameinUI.vbs"



              5. Create a VBS file (which you run at the end of the batch file) to find YOUR username in the UI file and replace it with the username of the person downloading the macros, since it won't work on their computer otherwise.



                Const ForReading = 1
                Const ForWriting = 2

                'get username
                username= CreateObject("WScript.Network").UserName

                'change this to the local location for outlook UI
                uiPath = "C:Users" & username & "AppDataLocalMicrosoftOfficeExcel.officeUI"

                'open the UI file in notepad, find & replace with new username
                Set objFSO = CreateObject("Scripting.FileSystemObject")
                Set objFile = objFSO.OpenTextFile(uiPath, ForReading)
                strText = objFile.ReadAll
                objFile.Close
                strNewText = Replace(strText, "your user name", username)
                Set objFile = objFSO.OpenTextFile(uiPath, ForWriting)
                objFile.WriteLine strNewText
                objFile.close

                msgbox "Completed!"






              share|improve this answer



























                1














                I think you could do it programatically. I have a process for sharing my Excel macros/ribbon, and you could try modifying it for Outlook. I'd be curious as to whether it works the same, since I'd like to eventually share my outlook macros as well. All the user has to do is run a batch file. There are a couple of components:



                1. Create a folder in a shared directory, where you can store your personal macros and ribbon.


                2. Copy over your macros from your local folder. For Excel, I copied over my personal excel file where I store my macros, out of C:UsersusernameAppDataRoamingMicrosoftExcelXLSTART. For Outlook, I assume you'd use the VbaProject.OPM file in C:UsersusernameAppDataRoamingMicrosoftOutlook.


                3. Copy over your UI file (ribbon) from your local folder: C:UsersusernameAppDataLocalMicrosoftOffice. The Excel ribbon is called Excel.officeUI, and I assume the Outlook ribbon is the file called olkexplorer.officeUI.



                4. Create your batch file, which will Copy the macros and UI out of the shared directory and on to the user's local drive. It will then call a VBS file which will slightly modify the UI file, replacing occurrences of your username with the user's username. I'm new to batch files and not sure how to insert comments into the code, but you should modify the first path (use the above path where the Outlook OPM file is stored), as well as the name of the macro file and the UI file (VbaProject.OPM and olkexplorer.officeUI).



                   Echo off
                  cls
                  Echo Please ensure that Excel(Outlook) is closed before continuing.
                  pause
                  cls

                  cd YourSharedDirectory
                  copy PERSONAL.XLSB c:users%USERNAME%AppDataRoamingMicrosoftExcelXLSTART*.* /y
                  cls

                  cd YourSharedDirectory
                  copy Excel.officeUI C:Users%USERNAME%AppDataLocalMicrosoftOffice*.* /y
                  cls

                  @echo off
                  wscript "findReplaceUserNameinUI.vbs"



                5. Create a VBS file (which you run at the end of the batch file) to find YOUR username in the UI file and replace it with the username of the person downloading the macros, since it won't work on their computer otherwise.



                  Const ForReading = 1
                  Const ForWriting = 2

                  'get username
                  username= CreateObject("WScript.Network").UserName

                  'change this to the local location for outlook UI
                  uiPath = "C:Users" & username & "AppDataLocalMicrosoftOfficeExcel.officeUI"

                  'open the UI file in notepad, find & replace with new username
                  Set objFSO = CreateObject("Scripting.FileSystemObject")
                  Set objFile = objFSO.OpenTextFile(uiPath, ForReading)
                  strText = objFile.ReadAll
                  objFile.Close
                  strNewText = Replace(strText, "your user name", username)
                  Set objFile = objFSO.OpenTextFile(uiPath, ForWriting)
                  objFile.WriteLine strNewText
                  objFile.close

                  msgbox "Completed!"






                share|improve this answer

























                  1












                  1








                  1







                  I think you could do it programatically. I have a process for sharing my Excel macros/ribbon, and you could try modifying it for Outlook. I'd be curious as to whether it works the same, since I'd like to eventually share my outlook macros as well. All the user has to do is run a batch file. There are a couple of components:



                  1. Create a folder in a shared directory, where you can store your personal macros and ribbon.


                  2. Copy over your macros from your local folder. For Excel, I copied over my personal excel file where I store my macros, out of C:UsersusernameAppDataRoamingMicrosoftExcelXLSTART. For Outlook, I assume you'd use the VbaProject.OPM file in C:UsersusernameAppDataRoamingMicrosoftOutlook.


                  3. Copy over your UI file (ribbon) from your local folder: C:UsersusernameAppDataLocalMicrosoftOffice. The Excel ribbon is called Excel.officeUI, and I assume the Outlook ribbon is the file called olkexplorer.officeUI.



                  4. Create your batch file, which will Copy the macros and UI out of the shared directory and on to the user's local drive. It will then call a VBS file which will slightly modify the UI file, replacing occurrences of your username with the user's username. I'm new to batch files and not sure how to insert comments into the code, but you should modify the first path (use the above path where the Outlook OPM file is stored), as well as the name of the macro file and the UI file (VbaProject.OPM and olkexplorer.officeUI).



                     Echo off
                    cls
                    Echo Please ensure that Excel(Outlook) is closed before continuing.
                    pause
                    cls

                    cd YourSharedDirectory
                    copy PERSONAL.XLSB c:users%USERNAME%AppDataRoamingMicrosoftExcelXLSTART*.* /y
                    cls

                    cd YourSharedDirectory
                    copy Excel.officeUI C:Users%USERNAME%AppDataLocalMicrosoftOffice*.* /y
                    cls

                    @echo off
                    wscript "findReplaceUserNameinUI.vbs"



                  5. Create a VBS file (which you run at the end of the batch file) to find YOUR username in the UI file and replace it with the username of the person downloading the macros, since it won't work on their computer otherwise.



                    Const ForReading = 1
                    Const ForWriting = 2

                    'get username
                    username= CreateObject("WScript.Network").UserName

                    'change this to the local location for outlook UI
                    uiPath = "C:Users" & username & "AppDataLocalMicrosoftOfficeExcel.officeUI"

                    'open the UI file in notepad, find & replace with new username
                    Set objFSO = CreateObject("Scripting.FileSystemObject")
                    Set objFile = objFSO.OpenTextFile(uiPath, ForReading)
                    strText = objFile.ReadAll
                    objFile.Close
                    strNewText = Replace(strText, "your user name", username)
                    Set objFile = objFSO.OpenTextFile(uiPath, ForWriting)
                    objFile.WriteLine strNewText
                    objFile.close

                    msgbox "Completed!"






                  share|improve this answer













                  I think you could do it programatically. I have a process for sharing my Excel macros/ribbon, and you could try modifying it for Outlook. I'd be curious as to whether it works the same, since I'd like to eventually share my outlook macros as well. All the user has to do is run a batch file. There are a couple of components:



                  1. Create a folder in a shared directory, where you can store your personal macros and ribbon.


                  2. Copy over your macros from your local folder. For Excel, I copied over my personal excel file where I store my macros, out of C:UsersusernameAppDataRoamingMicrosoftExcelXLSTART. For Outlook, I assume you'd use the VbaProject.OPM file in C:UsersusernameAppDataRoamingMicrosoftOutlook.


                  3. Copy over your UI file (ribbon) from your local folder: C:UsersusernameAppDataLocalMicrosoftOffice. The Excel ribbon is called Excel.officeUI, and I assume the Outlook ribbon is the file called olkexplorer.officeUI.



                  4. Create your batch file, which will Copy the macros and UI out of the shared directory and on to the user's local drive. It will then call a VBS file which will slightly modify the UI file, replacing occurrences of your username with the user's username. I'm new to batch files and not sure how to insert comments into the code, but you should modify the first path (use the above path where the Outlook OPM file is stored), as well as the name of the macro file and the UI file (VbaProject.OPM and olkexplorer.officeUI).



                     Echo off
                    cls
                    Echo Please ensure that Excel(Outlook) is closed before continuing.
                    pause
                    cls

                    cd YourSharedDirectory
                    copy PERSONAL.XLSB c:users%USERNAME%AppDataRoamingMicrosoftExcelXLSTART*.* /y
                    cls

                    cd YourSharedDirectory
                    copy Excel.officeUI C:Users%USERNAME%AppDataLocalMicrosoftOffice*.* /y
                    cls

                    @echo off
                    wscript "findReplaceUserNameinUI.vbs"



                  5. Create a VBS file (which you run at the end of the batch file) to find YOUR username in the UI file and replace it with the username of the person downloading the macros, since it won't work on their computer otherwise.



                    Const ForReading = 1
                    Const ForWriting = 2

                    'get username
                    username= CreateObject("WScript.Network").UserName

                    'change this to the local location for outlook UI
                    uiPath = "C:Users" & username & "AppDataLocalMicrosoftOfficeExcel.officeUI"

                    'open the UI file in notepad, find & replace with new username
                    Set objFSO = CreateObject("Scripting.FileSystemObject")
                    Set objFile = objFSO.OpenTextFile(uiPath, ForReading)
                    strText = objFile.ReadAll
                    objFile.Close
                    strNewText = Replace(strText, "your user name", username)
                    Set objFile = objFSO.OpenTextFile(uiPath, ForWriting)
                    objFile.WriteLine strNewText
                    objFile.close

                    msgbox "Completed!"







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 15 '18 at 18:20









                  user3597313user3597313

                  276




                  276























                      0














                      Outlook macro aren't made to be disitributed such as in Excel. You should build an add-in in .NET Framework using Office tools.



                      Here's an introduction : https://docs.microsoft.com/en-us/outlook/add-ins/quick-start?tabs=visual-studio



                      If you still want to export your macro, there are some workaround :



                      Solution 1



                      You can export modules as .bas, .cls, frx, and .frm files.Other users will have to reverse the process by importing them.



                      With this method no user will lose any code.



                      BUT



                      When importing the ThisOutlookSession module, it will be renamed ThisOutlookSession1. You'll have to copy the code from here and paste it in ThisOutlookSession or it won't run.



                      Solution 2



                      If the users don't have any macro project in their Outlook, you can copy (assuming there is only this macro on your Outlook) the VBAProject.OTM that you can find in %AppData%MicrosoftOutlook and overwrite the user's one with it.



                      The last method is the one I used when I had to share a macro. But if I knew it would be such a ****** I would have use VB.NET immediately. There are other solutions but I never experimented them.






                      share|improve this answer























                      • Hi Thanks for that. The only issue is that i had to create the button on the ribbon myself and then link the macro to it. Is there a way i would implement this into the code so that it would add the button to the ribbon when i distribute to the users.

                        – Will
                        Jun 19 '18 at 12:50











                      • I'm currently doing this, I'll let you know if I find a solution.

                        – Jérémy Gamba
                        Jun 22 '18 at 6:52











                      • Look at Roi-Kyi Bryant's answer on this post : stackoverflow.com/questions/8850836/… You can load a custom ribbon when opening your workbook. The disadvantage of this method is that you'll lost any previous customizations on your ribbon.

                        – Jérémy Gamba
                        Jun 22 '18 at 9:06















                      0














                      Outlook macro aren't made to be disitributed such as in Excel. You should build an add-in in .NET Framework using Office tools.



                      Here's an introduction : https://docs.microsoft.com/en-us/outlook/add-ins/quick-start?tabs=visual-studio



                      If you still want to export your macro, there are some workaround :



                      Solution 1



                      You can export modules as .bas, .cls, frx, and .frm files.Other users will have to reverse the process by importing them.



                      With this method no user will lose any code.



                      BUT



                      When importing the ThisOutlookSession module, it will be renamed ThisOutlookSession1. You'll have to copy the code from here and paste it in ThisOutlookSession or it won't run.



                      Solution 2



                      If the users don't have any macro project in their Outlook, you can copy (assuming there is only this macro on your Outlook) the VBAProject.OTM that you can find in %AppData%MicrosoftOutlook and overwrite the user's one with it.



                      The last method is the one I used when I had to share a macro. But if I knew it would be such a ****** I would have use VB.NET immediately. There are other solutions but I never experimented them.






                      share|improve this answer























                      • Hi Thanks for that. The only issue is that i had to create the button on the ribbon myself and then link the macro to it. Is there a way i would implement this into the code so that it would add the button to the ribbon when i distribute to the users.

                        – Will
                        Jun 19 '18 at 12:50











                      • I'm currently doing this, I'll let you know if I find a solution.

                        – Jérémy Gamba
                        Jun 22 '18 at 6:52











                      • Look at Roi-Kyi Bryant's answer on this post : stackoverflow.com/questions/8850836/… You can load a custom ribbon when opening your workbook. The disadvantage of this method is that you'll lost any previous customizations on your ribbon.

                        – Jérémy Gamba
                        Jun 22 '18 at 9:06













                      0












                      0








                      0







                      Outlook macro aren't made to be disitributed such as in Excel. You should build an add-in in .NET Framework using Office tools.



                      Here's an introduction : https://docs.microsoft.com/en-us/outlook/add-ins/quick-start?tabs=visual-studio



                      If you still want to export your macro, there are some workaround :



                      Solution 1



                      You can export modules as .bas, .cls, frx, and .frm files.Other users will have to reverse the process by importing them.



                      With this method no user will lose any code.



                      BUT



                      When importing the ThisOutlookSession module, it will be renamed ThisOutlookSession1. You'll have to copy the code from here and paste it in ThisOutlookSession or it won't run.



                      Solution 2



                      If the users don't have any macro project in their Outlook, you can copy (assuming there is only this macro on your Outlook) the VBAProject.OTM that you can find in %AppData%MicrosoftOutlook and overwrite the user's one with it.



                      The last method is the one I used when I had to share a macro. But if I knew it would be such a ****** I would have use VB.NET immediately. There are other solutions but I never experimented them.






                      share|improve this answer













                      Outlook macro aren't made to be disitributed such as in Excel. You should build an add-in in .NET Framework using Office tools.



                      Here's an introduction : https://docs.microsoft.com/en-us/outlook/add-ins/quick-start?tabs=visual-studio



                      If you still want to export your macro, there are some workaround :



                      Solution 1



                      You can export modules as .bas, .cls, frx, and .frm files.Other users will have to reverse the process by importing them.



                      With this method no user will lose any code.



                      BUT



                      When importing the ThisOutlookSession module, it will be renamed ThisOutlookSession1. You'll have to copy the code from here and paste it in ThisOutlookSession or it won't run.



                      Solution 2



                      If the users don't have any macro project in their Outlook, you can copy (assuming there is only this macro on your Outlook) the VBAProject.OTM that you can find in %AppData%MicrosoftOutlook and overwrite the user's one with it.



                      The last method is the one I used when I had to share a macro. But if I knew it would be such a ****** I would have use VB.NET immediately. There are other solutions but I never experimented them.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jun 19 '18 at 11:23









                      Jérémy GambaJérémy Gamba

                      659




                      659












                      • Hi Thanks for that. The only issue is that i had to create the button on the ribbon myself and then link the macro to it. Is there a way i would implement this into the code so that it would add the button to the ribbon when i distribute to the users.

                        – Will
                        Jun 19 '18 at 12:50











                      • I'm currently doing this, I'll let you know if I find a solution.

                        – Jérémy Gamba
                        Jun 22 '18 at 6:52











                      • Look at Roi-Kyi Bryant's answer on this post : stackoverflow.com/questions/8850836/… You can load a custom ribbon when opening your workbook. The disadvantage of this method is that you'll lost any previous customizations on your ribbon.

                        – Jérémy Gamba
                        Jun 22 '18 at 9:06

















                      • Hi Thanks for that. The only issue is that i had to create the button on the ribbon myself and then link the macro to it. Is there a way i would implement this into the code so that it would add the button to the ribbon when i distribute to the users.

                        – Will
                        Jun 19 '18 at 12:50











                      • I'm currently doing this, I'll let you know if I find a solution.

                        – Jérémy Gamba
                        Jun 22 '18 at 6:52











                      • Look at Roi-Kyi Bryant's answer on this post : stackoverflow.com/questions/8850836/… You can load a custom ribbon when opening your workbook. The disadvantage of this method is that you'll lost any previous customizations on your ribbon.

                        – Jérémy Gamba
                        Jun 22 '18 at 9:06
















                      Hi Thanks for that. The only issue is that i had to create the button on the ribbon myself and then link the macro to it. Is there a way i would implement this into the code so that it would add the button to the ribbon when i distribute to the users.

                      – Will
                      Jun 19 '18 at 12:50





                      Hi Thanks for that. The only issue is that i had to create the button on the ribbon myself and then link the macro to it. Is there a way i would implement this into the code so that it would add the button to the ribbon when i distribute to the users.

                      – Will
                      Jun 19 '18 at 12:50













                      I'm currently doing this, I'll let you know if I find a solution.

                      – Jérémy Gamba
                      Jun 22 '18 at 6:52





                      I'm currently doing this, I'll let you know if I find a solution.

                      – Jérémy Gamba
                      Jun 22 '18 at 6:52













                      Look at Roi-Kyi Bryant's answer on this post : stackoverflow.com/questions/8850836/… You can load a custom ribbon when opening your workbook. The disadvantage of this method is that you'll lost any previous customizations on your ribbon.

                      – Jérémy Gamba
                      Jun 22 '18 at 9:06





                      Look at Roi-Kyi Bryant's answer on this post : stackoverflow.com/questions/8850836/… You can load a custom ribbon when opening your workbook. The disadvantage of this method is that you'll lost any previous customizations on your ribbon.

                      – Jérémy Gamba
                      Jun 22 '18 at 9:06











                      0














                      VBA macros are not designed for distributing solutions on other/multiple machines. Moreover, VBA macros doesn't allow to customize the Fluent UI (aka Ribbon UI) programmatically. You need to develop a COM based add-in for these reasons. That is for they were invented! See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.



                      You can read more about the Fluent UI (aka Ribbon UI) in the following series of articles:



                      • Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

                      • Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

                      • Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

                      VSTO provides two main ways for creating a custom ribbon UI:



                      • Walkthrough: Create a custom tab by using the Ribbon Designer

                      • Walkthrough: Create a custom tab by using Ribbon XML

                      In case you still want share your VBA macro see To distribute Microsoft Outlook VBA code to other users for possible solutions.






                      share|improve this answer



























                        0














                        VBA macros are not designed for distributing solutions on other/multiple machines. Moreover, VBA macros doesn't allow to customize the Fluent UI (aka Ribbon UI) programmatically. You need to develop a COM based add-in for these reasons. That is for they were invented! See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.



                        You can read more about the Fluent UI (aka Ribbon UI) in the following series of articles:



                        • Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

                        • Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

                        • Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

                        VSTO provides two main ways for creating a custom ribbon UI:



                        • Walkthrough: Create a custom tab by using the Ribbon Designer

                        • Walkthrough: Create a custom tab by using Ribbon XML

                        In case you still want share your VBA macro see To distribute Microsoft Outlook VBA code to other users for possible solutions.






                        share|improve this answer

























                          0












                          0








                          0







                          VBA macros are not designed for distributing solutions on other/multiple machines. Moreover, VBA macros doesn't allow to customize the Fluent UI (aka Ribbon UI) programmatically. You need to develop a COM based add-in for these reasons. That is for they were invented! See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.



                          You can read more about the Fluent UI (aka Ribbon UI) in the following series of articles:



                          • Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

                          • Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

                          • Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

                          VSTO provides two main ways for creating a custom ribbon UI:



                          • Walkthrough: Create a custom tab by using the Ribbon Designer

                          • Walkthrough: Create a custom tab by using Ribbon XML

                          In case you still want share your VBA macro see To distribute Microsoft Outlook VBA code to other users for possible solutions.






                          share|improve this answer













                          VBA macros are not designed for distributing solutions on other/multiple machines. Moreover, VBA macros doesn't allow to customize the Fluent UI (aka Ribbon UI) programmatically. You need to develop a COM based add-in for these reasons. That is for they were invented! See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.



                          You can read more about the Fluent UI (aka Ribbon UI) in the following series of articles:



                          • Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

                          • Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

                          • Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

                          VSTO provides two main ways for creating a custom ribbon UI:



                          • Walkthrough: Create a custom tab by using the Ribbon Designer

                          • Walkthrough: Create a custom tab by using Ribbon XML

                          In case you still want share your VBA macro see To distribute Microsoft Outlook VBA code to other users for possible solutions.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jun 19 '18 at 13:42









                          Eugene AstafievEugene Astafiev

                          18.4k21026




                          18.4k21026



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50924994%2fpackage-outlook-vba-macro-with-custom-button-on-ribbon%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              這個網誌中的熱門文章

                              How to read a connectionString WITH PROVIDER in .NET Core?

                              In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

                              Museum of Modern and Contemporary Art of Trento and Rovereto