"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])

      hth
          Roger

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to