-
Re: Python in Excel
-
Add Sticky NoteGlobal 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()
For me it returns "C:\Documents and Settings\Administrator\My Documents",
which I needed to know at the time so I didn't have to screw around with
the ever annoying pythonpath.
You can put the first two lines of the function in the Workbook_Open hook,
but I don't know where that is. I hope to use more Python in Excel soon.
Hmm, actually, I suppose you can put those first two lines of the function
after the Global declaration as well. I know just about zero VBScript and
didn't get a chance to do anything else beyond proof of concept yet.
I figured I would write something dynamic which allowed more transparent
access to Python, maybe allowing formula like =py("os.getcwd()"), etc.
-
-
Script Excel from Python [python] [com] [excel]
-
A quick and dirty class for working with Excel via COM in Python. By far, not all of the power of Excel is available here, but it's a good start for simple tasks.
-
1 - 13 of 13
Showing 20▼ items per page
List Comments
(0)
List Info
Sponsored Links
Ads by Google
