Hi Roger, On 2/10/07, Roger Upole wrote: > "Andrea Gavana" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi All, > > > > I have a very simple python script that tries to put a rectangular > > shape in a worksheet and then add some text inside that shape. The > > main problem, is that as usual Excel doesn't like input strings longer > > than 200 and something characters. So, By just recording a macro in > > Excel, I tried to append the text in the shape by dividing it in > > chunks. For example, I tried this little script: > > > > #---------------------------------- > > from win32com.client import Dispatch > > > > finalText = "A"*1250 > > > > xlsapp = Dispatch("Excel.Application") > > wb = xlsapp.Workbooks.Add() > > sheet = wb.Sheets[0] > > > > myShape = sheet.Shapes.AddShape(1, 315, 200, 400, 300) > > myShape.Select() > > > > xlsapp.Selection.Characters.Text = finalText[0:200] > > xlsapp.Selection.Characters(200).Insert(finalText[200:400]) > > This looks like one of those odd properties that takes parameters. > There's a method for dynamic dispatches that you can use to > force it to be treated as a method: > > s=win32com.client.dynamic.DumbDispatch(xlsapp.Selection) > s._FlagAsMethod('Characters') > s.Characters(200).Insert(finalText[200:400]) >
Thank you for your help, it works like a charm! I didn't even know about "properties that take parameters" :-D Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77/ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32