Hello all,

Please excuse me if what I'm asking is trivial but I'm just starting with 
anything .net related and ironpython. I have a little experience programing c++ 
and python but I'm not a professional programmer.
What I'm trying to do is write a macro for a program through its com 
connectivity. The reason is that I do not know much (and I don't like what I 
know) about VBA. I also would like to reuse code that I've written in pyhton.
The problem that I have is that I get an error message "HRESULT E_FAIL" when I 
try to do anything with the generated object. However, I can see that the 
application launches. In fact, what I think is the equivalent code in VB seems 
to work.
VB code:
Module Program
        Sub Main()
                Dim catia As INFITF.Application
                catia = CreateObject("CATIA.Application")
                'catia = 
System.Runtime.InteropServices.Marshal.getActiveObject("CATIA.Application")
                Console.Write(catia.Caption)
                Console.Write("  Press any key to continue . . . ")
                Console.ReadKey(True)
        End Sub
End Module

The code that I'm using in ironpython is:

import System
import INFITF
t = System.Type.GetTypeFromProgID("CATIA.Application")
CATIA = System.Activator.CreateInstance(t)
print CATIA.caption
print "final"

I can see the application starting too but as soon as I try to probe it or do 
something I get the error.
I'm sure missing something but I do not know what.
By the way I'm using sharpDevelop as IDE. It is one of the reason I would like 
to go this route, it facilitates me a lot any GUI that I may want to include.
I've been fighting with this for two days. I can connect and work using 
win32com in regular python but I'm not able to go that route with ironpython 
either.
thank you a lot for your time.

Alberto Fernandez
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to