[IronPython] IronPython Excel 2007 Interop on Vista - problem

António Piteira antonio.piteira at wtvision.com
Tue Mar 24 05:29:58 PDT 2009


Hello Utini,

 

Instead of ‘wsheet = wbook.Worksheets[1]’ try this ‘wsheet =
wbook.Worksheets.Item[1]’.

 

It should work like that.

 

Good luck,

António Piteira

 

-------------------

 

It appears that the default Workbook.Add always includes 3 Worksheets.

2009/3/24 Dody Gunawinata <empirebuilder at gmail.com>

Does workbook automatically generates default worksheets when you create
them? It looks like an array out of bound problem.

2009/3/24 Utini <utinimail at gmail.com>

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.

 

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




-- 
nomadlife.org <http://nomadlife.org/> 


_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20090324/50d92cc6/attachment.htm>


More information about the Users mailing list