excel centering columns
Lance Hoffmeyer
lance at augustmail.com
Wed May 17 18:50:38 EDT 2006
Hey all,
Having problems centering a column
Can someone explain how to center a column using python?
import win32com.client
import re
import codecs
import win32com.client.dynamic
import time
import datetime
from win32com.client.dynamic import Dispatch
from win32com.client import constants
t2 = win32com.client.Dispatch("Excel.Application")
t2.Visible=1
wb = t2.Workbooks.Open (path + xltrack)
sh2 = wb.Worksheets (sheet)
lastcol = sh2.UsedRange.Columns.Count
sh2.Columns(lastcol).HorizontalAlignment = xlCenter
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
NameError: name 'xlCenter' is not defined
sh2.Columns(lastcol).HorizontalAlignment = constant.xlCenter
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
NameError: name 'constant' is not defined
sh2.Columns(lastcol).HorizontalAlignment = -4108
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 455, in __getattr__
return self._ApplyTypes_(*args)
File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_
return self._get_good_object_(
com_error: (-2146827864, 'OLE error 0x800a01a8', None, None)
More information about the Python-list
mailing list