Jeremy Palmer
Jeremy Palmer

Reputation: 11

Using win32com with excel I added a textbox to chart, how do I assign a formula to that textbox

I can add the textbox:

 x = chart.Shapes.AddTextbox(msoTextOrientationHorizontal, 180, 8.75, 31.5, 21)

I can write text in the box:

 x.TextFrame2.TextRange.Characters.Text = 50

I did a macro recording in excel and added a formula:

 ActiveSheet.Shapes.Range(Array("TextBox 2")).Select
 Selection.Formula = "=$F$2"

But I can not figure out how to set it from win32com. The .Formula doesn't seem to be under the Shape, or under TextFrame2 or TextRange or Characters. Not sure where else to look.

Upvotes: 0

Views: 67

Answers (1)

Jeremy Palmer
Jeremy Palmer

Reputation: 11

Finally, found it.

 chart.TextBoxes(2).Formula = "=$F$2"

Upvotes: 1

Related Questions