Excel ShapeRange problem with win32com

2006-03-15 Thread koia
Hi,

I have a problem with adding attributes to a Line in an Excel drawing
using the Python win32com interface. From recording in Excel I get the
Macro:

Sub Makro1()
ActiveSheet.Shapes.AddLine(192.75, 63.75, 316.5, 110.25).Select
Selection.ShapeRange.Line.ForeColor.SchemeColor = 10
Selection.ShapeRange.Line.Visible = msoTrue
End Sub

I want to replicate this from Python24 using the win32com interface:

import win32com.client.dynamic
xlapp = win32com.client.dynamic.Dispatch("Excel.Application")
xlapp.Visible = True
xlbook = xlapp.Workbooks.Add()
xlapp.ActiveSheet.Shapes.AddLine( 0, 0, 100, 100).Select
>

xlapp.Selection.ShapeRange.Line.ForeColor.SchemeColor = 10

This fails on ShapeRange, with output listed below. What can the
problem be? Is there a solution/work-around?

Thanks in advance
/koia

Traceback (most recent call last):
  File "C:\Program Files\ActiveState Komodo
3.5\lib\support\dbgp\pythonlib\dbgp\client.py", line 3180, in runcode
locals = self.frame.f_locals)
  File "C:\Program Files\ActiveState Komodo
3.5\lib\support\dbgp\pythonlib\dbgp\client.py", line 1574, in runcode
h_exec(code, globals=globals, locals=locals, module=module)
  File "C:\Program Files\ActiveState Komodo
3.5\lib\support\dbgp\pythonlib\dbgp\client.py", line 516, in __init__
exec code in globals, locals
  File "", line 0, in __main__
  File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
489, in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: .ShapeRange

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel ShapeRange problem with win32com

2006-03-15 Thread koia
Sorry guys,

I forgot the parenthesis in

xlapp.ActiveSheet.Shapes.AddLine( 0, 0, 100, 100).Select()

/koia

-- 
http://mail.python.org/mailman/listinfo/python-list


Passing parameters to VB

2006-03-19 Thread koia
Hi,

I am using win32com for the Python interface to my Excel shreadsheets.

When I turn on Macro recordiong in Excel while filling a rectangle with
text information, a part of the VB code produced is the following:

With Selection.Characters(Start:=1, Length:=11).Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic

What is the syntax for passing the parameters Start:=1, Length:=11 to
VB from a Python function, if I want to control these properties of the
text in the Excel spreadsheet?

Thanks in advance!

/ koia

-- 
http://mail.python.org/mailman/listinfo/python-list