run an Excel Macro from Python (but an Excel process stays in memory)

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 !! ;)

Answers


I don't know Python, but you need to use:

xl.Quit

Need Your Help

No reader matches PNG-Stream in Java.ImageIO

java image png javax.imageio

I'm trying to read the meta-data of a PNG file with java following the solution proposed here.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.