Python as an Excel scripting language
Let us do scripting with Python! Yay! Not only as an alternative to VBA, but also as an alternative to field functions (=SUM(A1:A2))
Thank you to all those participated in our survey. What an amazing number of responses, many of them with very deep content. We’re processing the over ten thousand responses(!), and already appreciate the time so many of you took to answer with passion and experience.
Please know this survey is used to help influence various topics – both on Python as well as other related topics that the comments started to bleed into. Given the passion, I want to be clear this remains an area of exploration for us, without any specific timeline.
We’ll provide updates as we progress on this feature request.
Lead Program Manager
Yes I agree. Any word yet? Not sure If it has been addressed but IMHO it also needs to integrate the macro recorder with python. The recorder is an excellent way to learn the Excel object model.
Echoing the comments of others, just wondering if there is an update on this
Any updates to this please? When are you planning to Roll it?
Alex Reed commented
Now I can't speak for Mac users, but if you're a Windows' User, you can technically start integrating the whole VBA object model with Python.
For example, if I want to copy between Excel & PowerPoint using Python I can do this with Win32 Python library, this allows us to plugin to the Windows' API and control different objects.
One of the coolest things about this library is that if use it inside of a Jupyter notebook I can run Python code real time inside of my Excel workbook. This means I can make API calls, dump data into Excel or even upload data to a Python object.
If, for example, you wanted to run Pandas real time inside of Excel this is also possible. The only reason I know this is I've written some scripts that will allow me to do this.
Now the documentation for all of this is few and far between; it's just not covered very well. This is why I started making YouTube videos on it because it changes the way we can look at Office and I know people could benefit from it. Using Python with Excel VBA is one of those things for some reason that never got out, and I don't think people ever realized you could do it.
If you want to check out the videos I made a playlist that covers some introduction topics:
Bill Tubbs commented
I think trying to integrate Python with Excel would be like putting lipstick on a pig. We really need a complete re-design of Excel’s underlying data structures, objects, functions, the formula writing language, how it allocates memory and the calculation method. This would hopefully solve the long-standing problems with crashes and lost work that we all experience on a regular basis. When these things are done it would be a good time to include a good scripting language like Python.
Jamal Mahmoud commented
Monty Python commented
Go for it !!!!
Excel and Python! Perfect! Excel + xlwings powered my application this year.
what have happened about it?
The best together. Python and Excel
Henrik Sylvin commented
I love Excel and Python!
Being able to script Excel with Python would be great. It would be most useful if there were an API that could be used to run Excel using general-purpose Python scripts written in any environment. For example, I currently use xlwings to call Python user defined functions which, in turn, connect to other external tools, such as the DWSIM Standalone Thermodynamics Library. One further complication: that library is a .NET assembly, which means I also need pythonnet.
Anything that streamlines the process of exporting third-party calculation results to Excel would be appreciated. My end users expect a pure, simple spreadsheet interface, yet need to access functionality contained in complex tools.
Bruno Moretti commented
Am I dreaming? Please MSFT, you must do this =)
Brian Janiszewski commented
Any updates to this? Clearly we want it but I haven't heard anything for months
There are lots of python followers who might desire this!
Personally the visual basic origins are sound and most desirable.
Keep VBA at its root! Instead of including python directly, interface inward from Python to excel utilizing an API like you would with C/C++! If field function changes or alternates would be desireable I suggest you list them as suggested improvements individually and specify as to what you would change them to.
Many people have their language of choice, this was already mine please don't mess with a good thing! Try instead this above suggested interface. There is only one vote button I assume that means agree, I disagree however!
Steve Barnes commented
Actually why stop at python in Excel as an alternative to VBA, why not throughout the entire office suite?
- Python in Word - I already have some very useful python scripts such as Glossary Check &/or Generate that I run externally but it would be great to run internally. Being able to run the NLTK within Word would open some fantastic options as would Pillow & matplotlib.
- Python in Power Point - this would rock.
- Python in Access would let you do something with your data - pandas anybody?
- Python in Outlook - just as an example personalized Out of Office notifications, how long since I communicated with (in either direction) anybody from the purchasing department of a given company!
I am reasonably sure that the majority of the Office components use common components for VBA so this should actually simplify implementation.
Python in excel, does life get any better than that...
The simplest way to implement this would be the following:
Update ScriptControl for 64-bit (could simply use a daemon here)
Add Python to ScriptControl.
Allow addition of text files via VBE.
Watch the magic happen!
Dim o as new ScriptControl
ScriptControl.language = "Python"
Are there any updates on this? We work heavily in VBA and would prefer this to remain or have plenty of notice of change.