How can a form with command buttons created with VSTA run macros made with VBA?

Hello,
How can a form with command buttons created with VSTA run macros made with VBA?
Greetings!
Parents
No Data
Reply
  •  1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
           [CgsAddInMacro]
            public void GetMacros()
            {
                if (!corelApp.InitializeVBA())
                    return;
                GMSProjects projects = corelApp.GMSManager.Projects;
                for (int i = 1; i <= projects.Count; i++)
                {
                    GMSMacros macros = projects[i].Macros;
                    for (int r = 1; r <= macros.Count; r++)
                    {
                        string name = macros[r].Name;
                        MessageBox.Show(name);
                    }
                }
            }
    
    
            [CgsAddInMacro]
            public void LoadMacro()
            {
                if (!corelApp.InitializeVBA())
                    return;
                string path = @"D:\Downloads\Shaping-X64-2023.gms";
                GMSProject gmp = corelApp.GMSManager.Projects.Load(path);
    
                GMSMacros macros = gmp.Macros;
         
                for (int r = 1; r <= macros.Count; r++)
                {
                    string name = macros[r].Name;
              
                    if (name.Equals("Shapes.Go"))
                    {
                       
                        macros[r].Run();
                        
                    }
                }
                gmp.Unload();
            }
            [CgsAddInMacro]
            public void LoadMacro2()
            {
                if (!corelApp.InitializeVBA())
                    return;
                string path = @"D:\Downloads\Shaping-X64-2023.gms";
                corelApp.GMSManager.RunMacro("Shaping2023", "Shapes.Go");
                
            }
    
Children