Question

What is the way to get access to XLSX textbox object using c#? Currently I am trying the following code and got a COM exception.

Excel.OLEObject obj1 = (Excel.OLEObject)(worksheet.OLEObjects("myTextBox"));
MSForm.TextBox textBox = (MSForm.TextBox)(obj1.Object);
Was it helpful?

Solution

Got it. Used the following snippet:

Excel.Shape obj1 = (Excel.Shape)worksheet.Shapes.Item("myTextBox");

I was trying to set the text for this textbox. Did it using

 obj1.TextFrame.Characters().Text = "myText";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top