0

I'm trying to turn-on Auto-Filter in Excel for some cells at row 5, preferably using Python Win32.

For example:

from win32com.client import Dispatch
xl = Dispatch("Excel.Application")
xl.Workbooks.Open(<file name>)
xl.ActiveWorkbook.ActiveSheet.Range('A5:D5').AutoFilter()
xl.ActiveWorkbook.Close(SaveChanges=1)
del(xl)

It still creates Auto Filter in the first row. Update: It works correctly, see comments.

I know that it is possible to set AutoFilter using ActiveSheet.Columns property, but it implies first row?

I'm using Windows XP, with Excel 2002 installed.

  • I ran that code from the terminal and got the expected result (saved AutoFilter on row 5 for the specified columns). Is that the exact code you're using? I only ask because it looks similar to code from another example (http://stackoverflow.com/questions/1948224/how-to-create-an-excel-file-with-an-autofilter-in-the-first-row-with-xlwt) and maybe it got messed up in your version? – RocketDonkey Aug 14 '12 at 19:32
  • @RocketDonkey, Thank you, I found a mistake in my range expression calculation, it works now. – Michael Gvirtzman Aug 15 '12 at 08:30

0 Answers0