<div dir="ltr">Does workbook automatically generates default worksheets when you create them? It looks like an array out of bound problem.<br><br><div class="gmail_quote">2009/3/24 Utini <span dir="ltr">&lt;<a href="mailto:utinimail@gmail.com">utinimail@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div>Hi all,</div>
<div> </div>
<div>I&#39;m attempting to automate Excel 2007 using IronPython 2.0.1. I&#39;ve followed a couple of examples (which I gather were written against Excel 2003), but they don&#39;t work for me.</div>
<div> </div>
<div>Here&#39;s my code:</div>
<div> </div>
<div>import clr<br>clr.AddReference(&#39;Microsoft.Office.Interop.Excel&#39;)<br>import Microsoft.Office.Interop.Excel as Excel<br>xlApp = Excel.ApplicationClass()<br>xlApp.Visible = True<br>wbook = xlApp.Workbooks.Add()<br>

wsheet = wbook.Worksheets[1] # produces an error</div>
<div> </div>
<div>The error I get is:</div>
<div> </div>
<div>Error while invoking _Default.<br>   at Microsoft.Scripting.Com.ComRuntimeHelpers.CheckThrowException(Int32 hresul<br>t, ExcepInfo&amp; excepInfo, UInt32 argErr, String message)<br>   at _stub_$27##25(Closure , CallSite , DispCallable )<br>

   at Microsoft.Scripting.Actions.MatchCaller.Call1[T0,TRet](Func`3 target, Call<br>Site site, Object[] args)<br>   at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)<br>   at Microsoft.Scripting.Actions.UpdateDelegates.Update1[T,T0,TRet](CallSite si<br>

te, T0 arg0)<br>   at _stub_$26##24(Closure , CallSite , ComObject , Int32 )<br>   at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 target, C<br>allSite site, Object[] args)<br>   at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)<br>

   at Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite<br> site, T0 arg0, T1 arg1)<br>   at _stub_$25##23(Closure , CallSite , Object , Int32 )<br>   at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 target, C<br>

allSite site, Object[] args)<br>   at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)<br>   at Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite<br> site, T0 arg0, T1 arg1)<br>

   at S$2.Initialize(Scope $scope, LanguageContext $language)<br>   at Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpress<br>ion code, Scope scope)<br>   at Microsoft.Scripting.ScriptCode.Run(Scope scope)<br>

   at IronPython.Hosting.PythonCommandLine.RunFileWorker(String fileName)<br>   at IronPython.Hosting.PythonCommandLine.RunFile(String fileName)<br>StandardError: Error while invoking _Default.</div>
<div> </div>
<div>Can anyone shed any light on this?</div>
<div> </div>
<div>Cheers,</div>
<div> </div>
<div>David.</div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><a href="http://nomadlife.org">nomadlife.org</a><br><br>
</div>