<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:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:D="DAV:" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<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;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 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;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.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=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>You probably want to take a copy of interp.py and modify it so
that when a dictionary is returned, you return something like the
Python.Dictionary object (see win32com\servers\dictionary.py).&nbsp; You can
create such an object via something like:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&gt;&gt;&gt; from win32com.servers.dictionary import
DictionaryPolicy<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&gt;&gt;&gt; from win32com.server.util import wrap<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&gt;&gt;&gt; ob = wrap({&quot;foo&quot;:&quot;bar&quot;},
usePolicy=DictionaryPolicy)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&gt;&gt;&gt; ob<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&lt;PyIDispatch at 0x01507A88 with obj at 0x01511620&gt;<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>If interp.py returned 'ob', VB should be able to access it
somewhat like a regular VB collection - so instead of simply:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return eval(str(exp),
self.dict)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>you checked the result, and if it&#8217;s a dict, execute the
lines above and return 'ob' instead of the dict (and obviously using a real
dict instead of the constant one in the example above)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hope this helps (and works ;)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Mark<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'>

<div>

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

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] <b>On
Behalf Of </b>Janakiraman Mohanakrishnan<br>
<b>Sent:</b> Tuesday, 5 February 2008 4:48 PM<br>
<b>To:</b> cappy2112@gmail.com<br>
<b>Cc:</b> bgailer@alum.rpi.edu; python-win32@python.org<br>
<b>Subject:</b> Re: [python-win32] Executing eval function in VBscript<o:p></o:p></span></p>

</div>

</div>

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

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>yes i want to
have python functionality in excel,</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>iam trying to
call python functions from VBscript,</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>more like
evaluating a python expression say dictionary or list in VBscript</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>For evaluating
a python expression , python has some library functions like eval which takes
python expressions</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;in string
format and checks whether it is a valid python expression or not</span> <br>
<br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>so i thought of
calling that python eval function in VBscript and validate my datas</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>but the problem
is when i tried to pass dictionaries for eg, &quot;{'key':value}&quot; this is
the format of dictionary in python</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>VBscript throws
error like type mismatch</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>since VB
dictionary representation of VB and python are different</span> <br>
<br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Thanks and
Regards!<br>
</span><br>
<br>
<o:p></o:p></p>

<table class=MsoNormalTable border=0 cellpadding=0 width="100%"
 style='width:100.0%'>
 <tr>
  <td width="40%" valign=top style='width:40.0%;padding:.75pt .75pt .75pt .75pt'>
  <p class=MsoNormal><b><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'>&quot;Tony
  Cappellini&quot; &lt;cappy2112@gmail.com&gt;</span></b><span
  style='font-size:7.5pt;font-family:"Arial","sans-serif"'> </span><o:p></o:p></p>
  <p><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'>02/05/2008
  01:51 AM</span> <o:p></o:p></p>
  <table class=MsoNormalTable border=1 cellpadding=0>
   <tr>
    <td valign=top style='background:white;padding:.75pt .75pt .75pt .75pt'>
    <p class=MsoNormal align=center style='text-align:center'><span
    style='font-size:7.5pt;font-family:"Arial","sans-serif"'>Please respond to<br>
    cappy2112@gmail.com</span><o:p></o:p></p>
    </td>
   </tr>
  </table>
  </td>
  <td width="59%" valign=top style='width:59.0%;padding:.75pt .75pt .75pt .75pt'>
  <table class=MsoNormalTable border=0 cellpadding=0 width="100%"
   style='width:100.0%'>
   <tr>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
    <p class=MsoNormal align=right style='text-align:right'><span
    style='font-size:7.5pt;font-family:"Arial","sans-serif"'>To</span><o:p></o:p></p>
    </td>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
    <p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'>python-win32@python.org</span>
    <o:p></o:p></p>
    </td>
   </tr>
   <tr>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
    <p class=MsoNormal align=right style='text-align:right'><span
    style='font-size:7.5pt;font-family:"Arial","sans-serif"'>cc</span><o:p></o:p></p>
    </td>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
    <p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'>bgailer@alum.rpi.edu,
    janakiraman.mohanakrishnan@tcs.com</span> <o:p></o:p></p>
    </td>
   </tr>
   <tr>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
    <p class=MsoNormal align=right style='text-align:right'><span
    style='font-size:7.5pt;font-family:"Arial","sans-serif"'>Subject</span><o:p></o:p></p>
    </td>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
    <p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'>[python-win32]
    Executing eval function in VBscript</span><o:p></o:p></p>
    </td>
   </tr>
  </table>
  <p class=MsoNormal><o:p>&nbsp;</o:p></p>
  <table class=MsoNormalTable border=0 cellpadding=0>
   <tr>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'></td>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'></td>
   </tr>
  </table>
  </td>
 </tr>
</table>

<p class=MsoNormal><br>
<br>
<br>
<tt><span style='font-size:10.0pt'>Date: Mon, 04 Feb 2008 10:05:11 -0500</span></tt><span
style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt>From: bob gailer &lt;bgailer@alum.rpi.edu&gt;</tt><br>
<tt>Subject: Re: [python-win32] Executing eval function in VBscript</tt><br>
<tt>To: Janakiraman Mohanakrishnan &lt;janakiraman.mohanakrishnan@tcs.com&gt;</tt><br>
<tt>Cc: python-win32@python.org</tt><br>
<tt>Message-ID: &lt;47A729A7.5030709@alum.rpi.edu&gt;</tt><br>
<tt>Content-Type: text/plain; charset=ISO-8859-1; format=flowed</tt><br>
<br>
<tt>&gt;&gt;That's hard to answer until we know what you want to accomplish!
Tell us</tt><br>
<tt>&gt;&gt;more. What problem are you trying to solve?</tt><br>
<br>
<tt>I think he wants to have python functionality from excel, which is</tt><br>
<tt>what I'd like to accomplish as well.</tt><br>
<tt>(Python embedded into excel, as opposed to launching Excel from Python)</tt><br>
<br>
<br>
<br>
<tt>&gt;&gt;Also I'm not very familiar with MSScriptControl. I googled it and
found</tt><br>
<tt>&gt;&gt;no useful documentation. Do you have any references to it?</tt><br>
<tt>Everything you want to know about the MSScriptControl is on microsoft's
site.</tt><br>
</span><br>
<span style='font-size:7.5pt;font-family:"Arial","sans-serif";color:white'>ForwardSourceID:NT0000976E
&nbsp; &nbsp;</span> <o:p></o:p></p>

<pre>=====-----=====-----=====<o:p></o:p></pre><pre>Notice: The information contained in this e-mail<o:p></o:p></pre><pre>message and/or attachments to it may contain <o:p></o:p></pre><pre>confidential or privileged information. If you are <o:p></o:p></pre><pre>not the intended recipient, any dissemination, use, <o:p></o:p></pre><pre>review, distribution, printing or copying of the <o:p></o:p></pre><pre>information contained in this e-mail message <o:p></o:p></pre><pre>and/or attachments to it are strictly prohibited. If <o:p></o:p></pre><pre>you have received this communication in error, <o:p></o:p></pre><pre>please notify us by reply e-mail or telephone and <o:p></o:p></pre><pre>immediately and permanently delete the message <o:p></o:p></pre><pre>and any attachments. Thank you<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre><o:p>&nbsp;</o:p></pre></div>

</div>

</body>

</html>