Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'say,': 0.05; 'bits': 0.07; 'table.': 0.07; 'scripts': 0.09; 'python': 0.09; 'command.': 0.09; 'fetch': 0.09; 'pressing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'vba,': 0.09; 'looked': 0.10; 'def': 0.10; 'suggest': 0.11; '(but': 0.15; 'server,': 0.15; 'above?': 0.16; 'doesnt': 0.16; 'message-id:@dough.gmane.org': 0.16; 'received:173.11': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'storing': 0.16; 'url:oreilly': 0.16; 'way;': 0.16; 'instance,': 0.17; 'examples': 0.18; 'shell': 0.18; 'skip:" 40': 0.20; 'import': 0.21; 'skip:_ 20': 0.22; 'example': 0.23; 'programming': 0.23; 'this:': 0.23; "i've": 0.23; 'seems': 0.23; 'idea': 0.24; 'command': 0.24; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'appear': 0.26; 'looks': 0.26; 'creating': 0.26; 'extend': 0.26; 'ago': 0.27; 'implemented': 0.27; 'easiest': 0.27; 'interface': 0.27; 'there.': 0.28; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'skip:_ 10': 0.29; 'class': 0.29; "i'm": 0.29; 'maybe': 0.29; "skip:' 10": 0.30; 'performing': 0.30; 'button': 0.30; 'skip:- 10': 0.32; 'print': 0.32; 'control,': 0.33; 'to:addr :python-list': 0.33; 'excel': 0.33; 'likely': 0.33; 'thanks': 0.34; 'described': 0.35; 'doing': 0.35; 'subject:?': 0.35; 'there': 0.35; 'received:org': 0.36; 'created': 0.36; 'but': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'mean': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'days': 0.60; 'skip:n 10': 0.63; 'more': 0.63; 'our': 0.65; 'e-mail,': 0.66; 'soon': 0.70; 'saw': 0.75; 'training': 0.78; 'goals': 0.78; 'net,': 0.84; 'sheet': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Emile van Sebille Subject: Re: Which way is best to execute a Python script in Excel? Date: Thu, 05 Jul 2012 07:28:39 -0700 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 173-11-108-137-sfba.hfc.comcastbusiness.net User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 71 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341498628 news.xs4all.nl 6843 [2001:888:2000:d::a6]:33800 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:24919 On 7/5/2012 12:22 AM Maurizio Spadaccino said... > Hi all > > I'm new to Python but soon after a few days of studying its features I > find it my favourite mean of programming scripts to allow for data > storing and mining. My idea would be to inplement python scripts from > inside an excel sheet that would store and fetch data from a Mysql > database. Look again at the com interface -- I've created excel commands implemented entirely in python this way and it will do everything you're looking for. Just start with some of the examples and extend from there. See http://oreilly.com/catalog/pythonwin32/chapter/ch12.html I did this ten years ago so things have likely changed, but the bits of the python script that set up com then looked like this: class fenxUtilities: _public_methods_ = [ 'FirstPartInsp' ] _reg_progid_ = "fenxDCom.Util" _reg_clsid_ = "{3EAD7AB4-2978-4360-8F7D-33FB36E9E146}" def FirstPartInsp(self,nomDiam, numFlutes, nomOAL, nomLOC): return EMSpecs(nomDiam, numFlutes, nomOAL, nomLOC).retvals if __name__=='__main__': print "Registering COM server..." import win32com.server.register win32com.server.register.UseCommandLine(fenxUtilities) HTH, Emile > So i need the script to be launched, say, by pressing a button > in excel and, for instance, retrieve immediately data from the mysql > table. For what I found in the net, it seems there are three ways to > control python from excel: > 1) run my python script via shell using the Run command in VBA, which > seems to me the easiest (but maybe slower?) way; > 2) creating a COM server, for which I need more training since it doesnt > appear that easy; > 3) via Microsoft Script Control, for which I saw some example around > where It looks like I can 'simulate' a python shell via the > 'executeStatement' command. > > What would you suggest would be the more performing way to achieve my > goals as described above? > > Thanks for you help > Maurizio > > > -- > Maurizio > > > www.mauriziospadaccino.com > --------------- > If you can avoid printing this e-mail, you are only doing good for our > planet. > >