Answer the question
In order to leave comments, you need to log in
How to set relative path for win32com excel object in python?
Now the code works, but in the workbook.SaveAs save line, the path is written manually. How can I correctly write the new_file_path variable there instead?
# -*- coding: utf-8 -*-
import win32com.client as win32
import os
excel = win32.Dispatch("Excel.Application")
workbook = excel.Workbooks.Add()
print('test')
print(os.path.dirname(__file__))
new_file_path = os.path.dirname(__file__) + "/UpdatedSheet.xls"
print(new_file_path)
workbook.SaveAs("D:\\Мои документы\\PyCharm\\Project_1\\Excel\\UpdatedSheet.xls")
workbook.close
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question