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()
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.