[IronPython] IronPython Excel 2007 Interop on Vista - problem

Utini utinimail at gmail.com
Tue Mar 24 12:46:55 CET 2009


Hi all,

I'm attempting to automate Excel 2007 using IronPython 2.0.1. I've followed
a couple of examples (which I gather were written against Excel 2003), but
they don't work for me.

Here's my code:

import clr
clr.AddReference('Microsoft.Office.Interop.Excel')
import Microsoft.Office.Interop.Excel as Excel
xlApp = Excel.ApplicationClass()
xlApp.Visible = True
wbook = xlApp.Workbooks.Add()
wsheet = wbook.Worksheets[1] # produces an error

The error I get is:

Error while invoking _Default.
   at Microsoft.Scripting.Com.ComRuntimeHelpers.CheckThrowException(Int32
hresul
t, ExcepInfo& excepInfo, UInt32 argErr, String message)
   at _stub_$27##25(Closure , CallSite , DispCallable )
   at Microsoft.Scripting.Actions.MatchCaller.Call1[T0,TRet](Func`3 target,
Call
Site site, Object[] args)
   at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
   at
Microsoft.Scripting.Actions.UpdateDelegates.Update1[T,T0,TRet](CallSite si
te, T0 arg0)
   at _stub_$26##24(Closure , CallSite , ComObject , Int32 )
   at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4
target, C
allSite site, Object[] args)
   at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
   at
Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite
 site, T0 arg0, T1 arg1)
   at _stub_$25##23(Closure , CallSite , Object , Int32 )
   at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4
target, C
allSite site, Object[] args)
   at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
   at
Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite
 site, T0 arg0, T1 arg1)
   at S$2.Initialize(Scope $scope, LanguageContext $language)
   at
Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpress
ion code, Scope scope)
   at Microsoft.Scripting.ScriptCode.Run(Scope scope)
   at IronPython.Hosting.PythonCommandLine.RunFileWorker(String fileName)
   at IronPython.Hosting.PythonCommandLine.RunFile(String fileName)
StandardError: Error while invoking _Default.

Can anyone shed any light on this?

Cheers,

David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090324/bf55badd/attachment.html>


More information about the Ironpython-users mailing list