with the following python method, I make a call to an Excel macro. I was happy when I got that to work, however I was wondering everytime I was executing this I could see a Windows temporary/lock file of the same name as the .XLA I was using the Macro from.
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)
When I open the task manager, I can see that an Excel process is still running… How to kill it but in a clean fashion when the job is done ? Is xl.Application.Run launching an asynchronous call to the Macro ? In which case it might be tricky…
Thanks guys !! 😉
I don’t know Python, but you need to use: