K
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
<bound method CDispatch.Select of <COMObject AddLine>>
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 "<console>", 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: <unknown>.ShapeRange
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
<bound method CDispatch.Select of <COMObject AddLine>>
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 "<console>", 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: <unknown>.ShapeRange