سؤال

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);
هل كانت مفيدة؟

المحلول

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";
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top