使用空格Python 3.8运行宏

使用空格Python 3.8运行宏,python,excel,python-3.x,vba,pywin32,Python,Excel,Python 3.x,Vba,Pywin32,我有以下代码: com_instance = Dispatch("Excel.Application") # USING WIN32COM com_instance.Visible = True com_instance.DisplayAlerts = False (file_path, file_name) = os.path.split(script_file) objworkbook = com_instance.Workbooks.Open(script_file) xlmodule

我有以下代码:

com_instance = Dispatch("Excel.Application") # USING WIN32COM
com_instance.Visible = True
com_instance.DisplayAlerts = False

(file_path, file_name) = os.path.split(script_file)
objworkbook = com_instance.Workbooks.Open(script_file)
xlmodule = objworkbook.VBProject.VBComponents.Add(1)
xlmodule.CodeModule.AddFromString(strcode.strip())
aux = "'"+ file_name + "'" + '!Module1.ExTracking'
com_instance.Application.Run(aux)
objworkbook.SaveAs(os.path.join(conv_scripts_dir, file_name))
com_instance.Quit()
但我得到了这个错误:

result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', 'Cannot run the macro "\'Tracking NS 29Ene20.xlsx\'!Module1.ExTracking". The macro may not be available in this workbook or all macros may be disabled.", u'xlmain11.chm', 0, -2146827284), None)
我不知道Python为什么在文件名中添加这些“\”,可能是因为这个原因


请帮帮我。谢谢

您能运行文件中已经存在的宏吗?您确定您的文件扩展名是
.xlsx
?如果是这样的话,你怎么能在里面有一个模块呢?我可以在Python3.5.2的pc上运行这段代码,但是当我在Python3.8的pc上运行它时,我得到了一个错误。(我无法安装Python3.5.2,因为它是我工作时的pc,所以我从windows应用商店安装了Python3.8)。请帮帮我