Update ActiveX ComboBox Control

Possible Usage Scenarios

You can read or write the values of ActiveX ComboBox Control using Aspose.Cells for Python via .NET. Please access the ActiveX Control via Shape.active_x_control property and check its type via ActiveXControl.type property, it should return ControlType.COMBO_BOX value and then typecast it into ComboBoxActiveXControl object and read or modify its various properties.

Please download the sample excel file used in the following sample code.

Update ActiveX ComboBox Control

The following screenshot shows the effect of the sample code on the sample excel file. As you can see, the ActiveX ComboBox value has been updated to “This is combo box control”.

todo:image_alt_text

Sample Code

The following sample code updates the value of ActiveX ComboBox Control present inside the sample excel file.

from aspose import pycore
from aspose.cells import Workbook
from aspose.cells.drawing.activexcontrols import ComboBoxActiveXControl, ControlType
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create a workbook
wb = Workbook(dataDir + "SourceFile.xlsx")
# Access first shape from first worksheet
shape = wb.worksheets[0].shapes[0]
# Access ActiveX ComboBox Control and update its value
if shape.active_x_control != None:
# Access Shape ActiveX Control
c = shape.active_x_control
# Check if ActiveX Control is ComboBox Control
if c.type == ControlType.COMBO_BOX:
# Type cast ActiveXControl into ComboBoxActiveXControl and change its value
comboBoxActiveX = pycore.cast(ComboBoxActiveXControl, c)
comboBoxActiveX.value = "This is combo box control with updated value."
# Save the workbook
wb.save(dataDir + "OutputFile_out.xlsx")