<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        color:black;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=PT link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span lang=EN-US style='color:black'>Hello Utini,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'>Instead of &#8216;</span><span
lang=EN-US>wsheet = wbook.Worksheets[1]<span style='color:black'>&#8217; try this &#8216;</span>wsheet
= wbook.Worksheets.Item[1]<span style='color:black'>&#8217;.<o:p></o:p></span></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'>It should work like
that.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'>Good luck,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'>António Piteira<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>-------------------</span></b><span lang=EN-US
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'><o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>It appears that the default
Workbook.Add always includes 3 Worksheets.<o:p></o:p></p>

<div>

<p class=MsoNormal>2009/3/24 Dody Gunawinata &lt;<a
href="mailto:empirebuilder@gmail.com">empirebuilder@gmail.com</a>&gt;<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'>Does workbook automatically
generates default worksheets when you create them? It looks like an array out
of bound problem.<o:p></o:p></p>

<div>

<p class=MsoNormal>2009/3/24 Utini &lt;<a href="mailto:utinimail@gmail.com"
target="_blank">utinimail@gmail.com</a>&gt;<o:p></o:p></p>

<div>

<div>

<div>

<p class=MsoNormal>Hi all,<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>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.<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>Here's my code:<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>import clr<br>
clr.AddReference('Microsoft.Office.Interop.Excel')<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<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>The error I get is:<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>Can anyone shed any light on this?<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>Cheers,<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>David.<o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">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><o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
<br clear=all>
<br>
-- <br>
<a href="http://nomadlife.org/" target="_blank">nomadlife.org</a><o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><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><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>