Hi Bill, Thanks for your answer, unfortunately it's still not working for me. I have installed the MSScriptControl.ScriptControl package but I still have the following error: "Run-time error '380'; A script engine for the specified language can not be created" when excel tries to execute the following line: sc1.Language = "python" of my vba script: VBA module: << Global sc1 As New MSScriptControl.ScriptControl Global sc2 As New MSScriptControl.ScriptControl Public Function os_getcwd() sc1.Language = "python" sc1.ExecuteStatement ("import os") os_getcwd = sc1.Eval("os.getcwd()") End Function Public Function vba_func() sc2.Language = "_vbscript_" vba_func = sc2.Eval("5+6^2") End Function >> The vba_func() can be used without any pb. So probably I have not installed MSScriptControl.ScriptControl properly or there is some thing witch is not configure properly in my excel environment. Is there something specific to do concerning the location of my Python environment? Could you please let me know what you have installed / configured to have the python script working. (if possible link(s) of the file(s) you have installed) Thanks in advance for any inputs you could provide to help me to progress. Best regards, Patrick Brown, William J wrote: Patrick, I was able to get this to work per the instructions in your link. You might make sure you have the ScriptControl installed properly.Bill ------------------------------------------------------- Attribute VB_Name = "Module1" Global sc As New MSScriptControl.ScriptControl Sub Main() End Sub Private Sub Workbook_Open() Application.WindowState = xlMaximized sc.Language = "python" sc.ExecuteStatement ("import os") os_getcwd = sc.Eval("os.getcwd()") resp = MsgBox(os_getcwd, vbInformation) End Sub ------------------------------------------------------ --------------- William Brown -------------- ----- Boeing Networked Systems Technology ----- Blvu:425.373.2738-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, November 07, 2008 12:00 PM To: activepython@listserv.ActiveState.com Subject: ActivePython Digest, Vol 15, Issue 2 Send ActivePython mailing list submissions to activepython@listserv.ActiveState.com To subscribe or unsubscribe via the World Wide Web, visit http://listserv.ActiveState.com/mailman/listinfo/activepython or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of ActivePython digest..." Today's Topics: 1. Python from Excel (Bruce Peterson) ---------------------------------------------------------------------- Message: 1 Date: Thu, 06 Nov 2008 15:14:19 -0800 From: Bruce Peterson <[EMAIL PROTECTED]> Subject: Python from Excel To: activepython@listserv.ActiveState.com Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii" The easiest way to do this is to covert your python code to be a COM server -- exposing the attributes and methods you want to call from Excel. Then link the COM object to Excel using VBA. see Hammon & Robinson Python Programming on Win32. Bruce At 12:00 PM 11/6/2008, you wrote:Hi, I would like to resuse a Python script in Excel2003environment, so Itry to develop a vba function to call this Python script function. I found the following example but unfortunately the 'python'languageis not recognize in my excel environment. Global sc As New MSScriptControl.ScriptControl Public Function os_getcwd() sc.Language = "python" sc.ExecuteStatement ("import os") os_getcwd = sc.Eval("os.getcwd()") End Function With this you can set your Excel formula to =os_getcwd() (http://www.velocityreviews.com/forums/t319222-re-python-in-excel.html)Do you have any idea how I could enable the python langage in a WindowsXP environment for Excel/VBA? Best regards, Patrick-------------- next part -------------- An HTML attachment was scrubbed... URL: http://listserv.ActiveState.com/pipermail/activepython/attachm ents/20081106/20f96580/attachment-0001.html ------------------------------ _______________________________________________ ActivePython mailing list ActivePython@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs End of ActivePython Digest, Vol 15, Issue 2 *******************************************_______________________________________________ ActivePython mailing list ActivePython@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython |
_______________________________________________ ActivePython mailing list ActivePython@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython