---------- Forwarded message ---------- From: Tim Golden <m...@timgolden.me.uk> Date: Sun, May 17, 2009 at 1:00 PM Subject: Re: [python-win32] Fwd: Autosizing column widths in Excel using win32com.client ? To: Cc: Python-Win32 List <python-wi...@python.org>
James Matthews wrote: > ---------- Forwarded message ---------- > From: <nonse...@mynonsense.net> > Date: Fri, May 15, 2009 at 7:45 PM > Subject: Autosizing column widths in Excel using win32com.client ? > To: python-list@python.org > > > 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 python-wi...@python.org http://mail.python.org/mailman/listinfo/python-win32 -- http://www.goldwatches.com
-- http://mail.python.org/mailman/listinfo/python-list