James Matthews wrote:
---------- Forwarded message ----------
From: <[email protected]>
Date: Fri, May 15, 2009 at 7:45 PM
Subject: Autosizing column widths in Excel using win32com.client ?
To: [email protected]


Is there a way to autosize the widths of the excel columns as when you
double click them manually?

Usual answer to this kind of question: record a macro
in Excel to do what you want, and then use COM to
automate that. On my Excel 2007, this is the VBA result
of recording:

<vba>
Sub Macro2()
'
' Macro2 Macro
'
'
   Columns("A:A").Select
   Range(Selection, Selection.End(xlToRight)).Select
   Columns("A:D").EntireColumn.AutoFit
End Sub
</vba>


You then just fire up win32com.client or comtypes,
according to taste and go from there. If you need
help with the COM side of things, post back here.

TJG
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to