Hello,How can a form with command buttons created with VSTA run macros made with VBA?Greetings!
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"); }
Hello,C# is not my best program language. Please explain, at least a little, how to use this code? Need I Visual Studio? I use Visual Studio 19Greetings!
for native coreldraw vsta support, you will need visual studio, I don't know the specific version as I don't use coreldraw's native vsta, but it doesn't make much sense to use vsta if you are not going to use c#, vba is better for small projects. i use c# because i have no interest in learning vba
Thank You for this answer!Problem is a little different. I will try to explain. But i think that only people using VSTA, VBA, CorelDraw may understand. Because theoretically all must work, but not work.
maybe it's a misunderstanding, I assumed you already had a VSTA form, which in CorelDraw's case is a WinForm form in C#.