Для этого у меня есть файл all_files.xlsm, который содержит кнопку с назначенными ей макросами. Макросы выглядят так:
Код: Выделить всё
Sub check_data()
RunPython ("import python_code; python_code.consolidation()")
End Sub
Я также использую Workbook.set_mock_caller(), чтобы иметь возможность запустить код через интерфейс Python. Выглядит это так:
Код: Выделить всё
def consolidation(file_path):
*** smth to get the data I need ***
...
*** after I got data ***
Range('A1').table.clear_contents() #string1
Range('A1').value = data #string2
def main():
consolidation(file_path)
if __name__ == '__main__':
xl.Workbook.set_mock_caller(path_to_file)
main()
Любая помощь и советы очень ценятся!
Подробнее здесь: https://stackoverflow.com/questions/341 ... ough-excel