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
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.
I would like to leave the cell blank if a certain condition is not respected and the formula above is my best gues. However, my final goal is then to plot all the cells of a column where this formula is applied, but I end up with a lot of "zeros" plotted because the cell is not actually considered blank. Is there a way to go around this problem?
Aravind S commented
MS Office is great application but people who can't wait can check "Libre Office" which support multiple "Macro scripting languages" by default.. which includes python...
It looks like there is no hope any more
Mehmet TEMEL commented
Please add integration with Jupyter notebooks (e.g. Azure Notebooks). Example using Google Sheets: http://www.countingcalculi.com/explanations/google_sheets_and_jupyter_notebooks/
The posibilities of this are really mind-blowing
@alpha6qcsDB you're right. However you forgot one thing: if MS provides just a good API, these tools can be used just by tech savvy people. If MS includes python in excel, sheets/workbooks could be crafted with python scripts and deploy the more people w/o provide support for installing excel add-ins and python virtual environments, so this will be more 'portable', efficient and less time-consuming.
Since Microsoft has embraced opensource.. it would be good if they just made good interfaces that other languages and frameworks could tie into.. and let the best one win. There are a huge number of existing python interfaces
6. Iron Python
There are atleast 10 more..
All these depend on the COM interface. So instead of trying to add another implementation to the mix. It would be good if MS made the COM interface more reliable, well documented for Excel.. and perhaps drive some resources to the opensource development of the basic libraries such as ctypes, comtype, win32 etc which the other libraries are dependent on.
Put us out of our misery, please...
Fabricio Biazzotto commented
It's already possible to do that, right know, with https://www.xlwings.org/
Record Macro and it's Python gets my vote
the folk at https://datanitro.com/ are doing something like that, when i saw their presentation years ago i was mind blown.
Vote for Python !
Plus, please add a modern bulit-in code editor in Excel for code editing, vs code may be the right one. VBE, the not smart dev env , really hurts.
Harvey Ellis commented
Some form of this is a very good idea. Building health economic models for clients in the pharmaceutical industry, it is nigh-on-impossible to get them to agree to anything but basic excel. Even R scripts, with code that is fully contained within a single script is difficult for them.
The main problem is versioning, and being able to provide a model in a single package - with no external dependencies. Therefore, I do wonder whether some of the more esoteric, but still rather useful packages would be supported in the Excel Python Interpreter. Perhaps there might be some kind "compartment" within the excel file for packages to be shipped within the file? (I am unsure how this might work.)
Or, perhaps as others have said, integrating VS code, with F#, C# or VB.NET support would be the way forward - allowing further extensibility, automation and performance whilst still within the Microsoft ecosystem.
In my opinion, adding the ability to writing Python scripts in excel in macros or as worksheet functions, is precisely same as connecting two closed oceans and get the advantage of boating on the vast open waters.
It is fantastic and I am ready to jump to that ocean.
This must happen please!!!