Which way is best to execute a Python script in Excel?

Emile van Sebille emile at fenx.com
Sat Jul 7 10:31:07 EDT 2012


On 7/7/2012 2:05 AM Maurizio Spadaccino said...
> Thanks again Emile, I'll try out some examples. I found this one: http://showmedo.com/videotutorials/video?name=2190050&fromSeriesID=219
> quite enlightning.
> One last doubt is: say the python code gets used by more Excel Users (different pc), can I include in some way a dinamic generation of the id in order to allow each pc to register is own COM server or do I have to hard code the id on each machine specifically?
>

Here's how to generate an ID, but it's likely not to occur on other 
machines.

 >>> import pythoncom; print pythoncom.CreateGuid()
{CE571F2A-6BD8-4A8D-9482-4EC02FAC171E}

There's an interesting perspective on uniqueness of guid's at

http://betterexplained.com/articles/the-quick-guide-to-guids/

So, create it once and hardcode it in.  If you provide new features in a 
subsequent version you may want to issue a new guid, particularly to 
develop a new version while still running the old on the same machine.

Each user will then need to have python and pythonwin installed, then 
run your com server to execute the com server registration piece in the 
"if __name__ == '__main__'" part of things.

Emile






More information about the Python-list mailing list