Free Support Forum -

Assign macros to controls via Aspose.Cells in .NET

The search function on your forums page does not appear to be working so pardon me if this has already been answered else where.

How do you assign a macro (that already exist in the Excel workbook) to a new ComboBox that you are adding to a worksheet? Below is sample code of how I am creating the new Combox, but I cannot find anything on how to assign a Macro to it. Your documentation page ( mentions being able to do it to a TextBox .... but never shows how.

Worksheet currentWorksheet = excelFile.Worksheets[11];

string lookupSheetName = "ISSUE_FILTER_ORG";

Aspose.Cells.Drawing.ComboBox newComboBox = currentWorksheet.Shapes.AddComboBox(6, 8, 1, 5, 22, 267);

newComboBox.DropDownLines = 8;

newComboBox.InputRange = string.Format("{0}!$C$3:$C$6", lookupSheetName);

newComboBox.LinkedCell = string.Format("{0}!$C$1", lookupSheetName);

//Assign a Macro to the ComboBox ??????

And finally, has the ability to add new macros been added to Aspose.Cells yet? We are currently licensed and using version


I am afraid, your requested feature of writing new macros and attaching macros to controls or running macros programmatically through Aspose.Cells is not supported at the moment. Aspose.Cells only supports to preserve the macros which are in your template file. It can also remove macros in the template files. But, it does not support to run, add/attach/update macros or vbas. We have already registered this feature in our internal work list with issue id: CELLSNET-13561. We may look into it in future versions though.

Thank you.


Thanks for using Aspose.Cells.

We only plan to create,
manipulate or embed VBA codes/ macros later. We however cannot support
to run or execute macros. Does it fit your needs?


You can now assign macros to controls via Aspose.Cells APIs. See the document with example code on how to Assign Macro to Form Control.

Over the years, Aspose.Cells has included more enhancements on the features, i.e., create, manipulate or remove vba codes/macros. We also recommend you see the documents in the section on how to manage/manipulate VBA code and macros for your complete reference:
Manage VBA Codes or Macros