Office COM automatisation - calling python from VBA

Josef Meile jmeile at hotmail.com
Sat Jun 25 07:07:59 EDT 2005


Hi guy,

> I'll be using COM, and I could probably make an application that
> controls Outlook (externally). But I'd also like to have this
> functionality exposed in OL itself. So I guess I'll need to use VBA,
> but I don't really like VBA - relax, please, it's just an opinion.. ;)
> 
> So, ideally, I'd like to program as much as possible in python (I'm
> pretty new to that, too, btw), and only use VBA if needed - say, to
> call python objects/methods (+ wxGUI, please).
You could try to do an addin/addon for Word, Excel, and Outlook. You
don't need to code with VBA. Here you just need a language from where
you can access the microsoft interop assemblies (ie: C++ or C#;
IronPython maybe?)

I'm now working in an addon for Visio, but I'm not using python. I'm
using C#. The main idea is that we have an exe application, which
creates a COM object, with the first running instance of visio (if some
is found). Then, I use a class (event handler) to catch some events
comming from visio (this is in part documented at the msdn). I even
embebbed a windows form in Visio (it was an example in the sdk).

So, I think in theory, you could do the same with python. I have heard
you can somehow create COM objects there. You could also try the new
version of python for net: IronPython. I guess you can from there access
all the assemblies to interact with office:

Microsoft.Office.Interop.Excel,
Microsoft.Office.Interop.Word, and
Microsoft.Office.Interop.Outlook

A good start is to see the SDK documentation of each office product you
need at each developer center in www.msdn.microsoft.com

Good luck,
Josef




More information about the Python-list mailing list