Should I use Python instead of VBA?

I am creating a demo (and a potentially small application) for a financial accounting model. I use VBA / Excel to enter data (for example, with forms), calculate and present the results, and I also run SQL queries in the MS Access database from the VBA program. In principle, the functionality of these components serves me quite well (I understand that VBA is a bit outdated, not the smoothest). I have been doing this for some time (and I am developing some ancient experience of other languages, although I have never worked as a programmer), and to a large extent managed things and, it seems, could find programming errors that I make. However, I tend to go crazy in VBA when errors happen that really aren't caused by me, but because of the instability / flaws with VBA.

So my question is what I'm totally inexperienced with Python: could I basically do with Python, which I described above? Could you give me an idea of ​​whether Python is more stable and less error prone than VBA / Excel? (I am using Windows 7) Thanks for the consultation

+4
source share
2 answers

If you decide to use Python to automate automation of Office applications, go to Python Win32 Extensions

However, I am skeptical that this is appropriate. This will require installing and learning Python. And if this is an application that you distribute to users, they will also need Python.

In addition, the following example of declaring variables indicates that your time will be better spent learning the VBA and object models of Office applications that you want to automate. In this example, you misinterpreted your lack of understanding of the basics of VBA because "VBA is error prone." Python will not help you with this.

+9
source

I would suggest you do this in Python. Python has become the default standard for data analysis. Microsoft is considering adding Python to excel: https://news.ycombinator.com/item?id=15927132

But it has not been added yet: https://excel.uservoice.com/forums/304921-excel-for-windows-desktop-application/suggestions/10549005-python-as-an-excel-scripting-language

However, everything you can do in VBA can be done with python and more using any of the following libraries:

Of these, I would suggest using Xlwings . I used it and it works flawlessly. You can even execute VBA through python code. That way, you have the best of both worlds, i.e. use any data analysis package in python to do your calculations, and when you need (but don’t have access to functions open by VBA but not supported by Xlwings initially), you can directly Call VBA functions in Excel.

0
source

Source: https://habr.com/ru/post/1392459/


All Articles