How to select a range with xlwings?

43 views Asked by At

I am attempting to select a range in order to freeze panes to a specific cell using xlwings.

import xlwings as xw

wb_output = xw.Book(output_file_path, update_links=False)
main_sheet = wb_output.sheets[main_sheet_name]

main_sheet.activate()
main_sheet.range('C3').api.Select()
print(f'Current Selection = {xw.apps.active.selection.address}')

main_sheet.api.Application.ActiveWindow.FreezePanes = True

My code is not working, as the output is "Current Selection = $AK$883" instead of cell C3.

I have been reading the xlwings documentation, and this appears to be the correct way to select a cell, yet it is not working, so what am I doing incorrectly?

0

There are 0 answers