In Excel VBA the code below selects the columns A to E.
worksheet.Columns(1).Resize(ColumnSize:=5).Select
But in Python (using the win32com.client
module) the code below doesn't work.
worksheet.Columns(1).Resize(ColumnSize=5).Select()
# TypeError: __call__() got an unexpected keyword argument 'ColumnSize'
worksheet.Columns(1).Resize(ColumnIndex=5).Select()
# pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146827284), None)
While the code below only selects the column E.
worksheet.Columns(1).Resize(5).Select()
worksheet.Columns(1).Resize(RowIndex=5).Select()
Workaround in the code below (I don't want to use worksheet.Columns('A:E')
because the number of columns varies).
worksheet.Range(Cell1=worksheet.Cells(RowIndex=1, ColumnIndex=1), Cell2=worksheet.Cells(RowIndex=1, ColumnIndex=5)).EntireColumn.Select()
My question is why does the resize not work as expected, is it a bug? If so, is there a proper place to report it? Should I use the workaround I provided, or something else?