使用以下 python 方法,我调用了 Excel 宏。当我开始工作时我很高兴,但是我想知道每次执行此操作时,我都可以看到一个与我使用宏的 .XLA 同名的 Windows 临时/锁定文件。
class XlaMakeUnmake:
__configFile = 'xla_svn.cfg'
__vbaTools = 'makeProtected.xla'
__entries = {}
def __init__(self):
self.__readConfig()
def __newDirs(self, dir):
try:
os.makedirs(dir)
except OSError, e:
if e.errno != errno.EEXIST:
raise
### WILL ONLY WORK FOR UNPROTECTED
'''
filePath: path of XLA to unmake
outputDir: folder in which the lightweight xla and its components will be pushed to
'''
def unmake(self, filePath, outputDir):
xl = win32com.client.Dispatch("Excel.Application")
xl.Visible = 0
self.__newDirs(outputDir)
xl.Application.Run("'" + os.getcwd() + os.sep + self.__vbaTools + "'!Unmake", filePath, outputDir)
当我打开任务管理器时,我可以看到一个 Excel 进程仍在运行......如何在工作完成后以干净的方式杀死它?正在xl.Application.Run
启动对宏的异步调用?在这种情况下,它可能会很棘手......
多谢你们 !!;)