none
How do I deploy a macro from gloabl mpt to enterprise mpt?

    Question

  • Hi, We have a macro and want to make it available to all via the enterprise global. What are the steps needed? Also how do we customise the ribbon and make the macro run from a button on the ribbon. Finally can we deploy the customised ribbon via the enterprise global?

    thanks in advance

    Steve

    Thursday, May 9, 2019 8:20 AM

Answers

  • Hi,

    to move macros into Enterprise Global (eGlobal), just open eGlobal. In Visual Basic Editor and add your code to the checked-out Enterprise Global. But I suggest to do first everything without checking out eGlobal for testing.

    To enable button in ribbon, add the following in "ThisProject" in EGlobal:

    Private Sub Project_Open(ByVal pj As Project)
    
    If Not pj Is Nothing Then
        If pj.Type = pjProjectTypeEnterpriseCheckedOut _
            Or pj.Type = pjProjectTypeEnterpriseReadOnly Then
            Call CustomizeRibbon(pj)
        End If
    End If
    End Sub

    Add the following in a module in EGlobal (after doing your adjustments and testing). This sample will create one group with two buttons for Macro1 and Macro2:

    Sub CustomizeRibbon(pj)
    'Ribbon erstellen
    Dim Custom_XML
    Dim MRXActions As String
    
    'Set pj = ActiveProject
    
    pj.SetCustomUI ("")
        
      On Error GoTo ErrorHandling
    
    
    
      '------------------ Define Ribbon -----------------------
      
    
         
      MRXActions = ""
      
            MRXActions = MRXActions + "<mso:group id=""MGTools"" label=""Tools"" autoScale=""true"">"  'ID for group
              MRXActions = MRXActions + "  <mso:button id=""MBMacro1"" "       'ID for Button
              MRXActions = MRXActions + "    label=""Define Label"" "
              MRXActions = MRXActions + "    size=""large"" imageMso=""VisualBasicReferences"" " 'Get available images from e.g. https://bert-toolkit.com/imagemso-list.html or search for other imageMSO lists
              MRXActions = MRXActions + "    screentip=""Define Screentip"" "
              MRXActions = MRXActions + "    supertip=""Define Subertip"" "
              MRXActions = MRXActions + "    onAction=""Macro1""/>"
              
              MRXActions = MRXActions + "  <mso:button id=""MBMacro2"" "       'ID for Button
              MRXActions = MRXActions + "    label=""Define Label"" "
              MRXActions = MRXActions + "    size=""large"" imageMso=""VisualBasicReferences"" " 'Get available images from e.g. https://bert-toolkit.com/imagemso-list.html or search for other imageMSO lists
              MRXActions = MRXActions + "    screentip=""Define Screentip"" "
              MRXActions = MRXActions + "    supertip=""Define Subertip"" "
              MRXActions = MRXActions + "    onAction=""Macro2""/>"
            MRXActions = MRXActions + "</mso:group>"
            
    
    
      '-------------------- Custom Ribbon  --------------------
      Custom_XML = ""
      Custom_XML = Custom_XML + "<mso:customUI xmlns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">"
      Custom_XML = Custom_XML + "  <mso:ribbon startFromScratch=""false"">"
      'Custom_XML = Custom_XML + "    <mso:qat/>"
      Custom_XML = Custom_XML + "    <mso:tabs>"
      Custom_XML = Custom_XML + "      <mso:tab id=""MTPost"" label=""Custom"" insertBeforeQ=""mso:TabFormat"">"
      
      Custom_XML = Custom_XML + MRXActions
       
      Custom_XML = Custom_XML + "      </mso:tab>"
      Custom_XML = Custom_XML + "    </mso:tabs>"
      Custom_XML = Custom_XML + "  </mso:ribbon>"
      Custom_XML = Custom_XML + "</mso:customUI>"
      
        
      '-------------------- Reset ribbon, apply custom version --------------------
      
      pj.SetCustomUI ("")
      pj.SetCustomUI (Custom_XML)
    
      Exit Sub
    ErrorHandling:
      MsgBox "Ribbon could not be created", vbInformation, "No customized ribbon"
    End Sub

    Does that help?
    Barbara

    • Marked as answer by Steve Yorks Thursday, May 9, 2019 11:30 AM
    Thursday, May 9, 2019 9:17 AM
    Moderator

All replies

  • Hi,

    to move macros into Enterprise Global (eGlobal), just open eGlobal. In Visual Basic Editor and add your code to the checked-out Enterprise Global. But I suggest to do first everything without checking out eGlobal for testing.

    To enable button in ribbon, add the following in "ThisProject" in EGlobal:

    Private Sub Project_Open(ByVal pj As Project)
    
    If Not pj Is Nothing Then
        If pj.Type = pjProjectTypeEnterpriseCheckedOut _
            Or pj.Type = pjProjectTypeEnterpriseReadOnly Then
            Call CustomizeRibbon(pj)
        End If
    End If
    End Sub

    Add the following in a module in EGlobal (after doing your adjustments and testing). This sample will create one group with two buttons for Macro1 and Macro2:

    Sub CustomizeRibbon(pj)
    'Ribbon erstellen
    Dim Custom_XML
    Dim MRXActions As String
    
    'Set pj = ActiveProject
    
    pj.SetCustomUI ("")
        
      On Error GoTo ErrorHandling
    
    
    
      '------------------ Define Ribbon -----------------------
      
    
         
      MRXActions = ""
      
            MRXActions = MRXActions + "<mso:group id=""MGTools"" label=""Tools"" autoScale=""true"">"  'ID for group
              MRXActions = MRXActions + "  <mso:button id=""MBMacro1"" "       'ID for Button
              MRXActions = MRXActions + "    label=""Define Label"" "
              MRXActions = MRXActions + "    size=""large"" imageMso=""VisualBasicReferences"" " 'Get available images from e.g. https://bert-toolkit.com/imagemso-list.html or search for other imageMSO lists
              MRXActions = MRXActions + "    screentip=""Define Screentip"" "
              MRXActions = MRXActions + "    supertip=""Define Subertip"" "
              MRXActions = MRXActions + "    onAction=""Macro1""/>"
              
              MRXActions = MRXActions + "  <mso:button id=""MBMacro2"" "       'ID for Button
              MRXActions = MRXActions + "    label=""Define Label"" "
              MRXActions = MRXActions + "    size=""large"" imageMso=""VisualBasicReferences"" " 'Get available images from e.g. https://bert-toolkit.com/imagemso-list.html or search for other imageMSO lists
              MRXActions = MRXActions + "    screentip=""Define Screentip"" "
              MRXActions = MRXActions + "    supertip=""Define Subertip"" "
              MRXActions = MRXActions + "    onAction=""Macro2""/>"
            MRXActions = MRXActions + "</mso:group>"
            
    
    
      '-------------------- Custom Ribbon  --------------------
      Custom_XML = ""
      Custom_XML = Custom_XML + "<mso:customUI xmlns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">"
      Custom_XML = Custom_XML + "  <mso:ribbon startFromScratch=""false"">"
      'Custom_XML = Custom_XML + "    <mso:qat/>"
      Custom_XML = Custom_XML + "    <mso:tabs>"
      Custom_XML = Custom_XML + "      <mso:tab id=""MTPost"" label=""Custom"" insertBeforeQ=""mso:TabFormat"">"
      
      Custom_XML = Custom_XML + MRXActions
       
      Custom_XML = Custom_XML + "      </mso:tab>"
      Custom_XML = Custom_XML + "    </mso:tabs>"
      Custom_XML = Custom_XML + "  </mso:ribbon>"
      Custom_XML = Custom_XML + "</mso:customUI>"
      
        
      '-------------------- Reset ribbon, apply custom version --------------------
      
      pj.SetCustomUI ("")
      pj.SetCustomUI (Custom_XML)
    
      Exit Sub
    ErrorHandling:
      MsgBox "Ribbon could not be created", vbInformation, "No customized ribbon"
    End Sub

    Does that help?
    Barbara

    • Marked as answer by Steve Yorks Thursday, May 9, 2019 11:30 AM
    Thursday, May 9, 2019 9:17 AM
    Moderator
  • Many Thanks Barbara, this looks good,

    I will give it a go,

    Much appreciated!

    Steve

    Thursday, May 9, 2019 11:32 AM
  • Hi Steve,

    just let me know if there are any issues. I anonymized the code - hopefully without adding any issues.

    Regards
    Barbara

    Thursday, May 9, 2019 11:51 AM
    Moderator