Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Is Python a suitable replacement for VBA?

 
Ranch Hand
Posts: 53
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question is for Albert. I actually have "Automate the Boring Stuff with Python" on my Amazon wish list. I'm a Java developer, but I may buy this for my brother and I may grab a copy for myself too. My brother is being tasked with learning VBA and automating things at his workplace. From the description of this book, Python sounds like a suitable modern replacement for VBA and other workplace scripting automation tools. Would you say that is correct?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Nielson wrote:Python sounds like a suitable modern replacement for VBA and other workplace scripting automation tools. Would you say that is correct?



Not Albert, but I think it depends on if interacting with Microsoft applications is a requirement. Python doesn't have any native functionality to do so, though there are some third-party tools available. Depending on how functional they are and how much functionality one requires, Python may or may not be a good choice.
 
Author
Posts: 31
5
Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tom. I would say yes. VBA as a language is... less than ideal. The syntax is a bit messy and it doesn't have a large package repo like Python (or Ruby or Perl) has. It's also limited to Windows.

The chief benefit of VBA is that it was the original language made for programmatically interacting with Excel spreadsheets. Chapter 12 of the book covers using the OpenPyXL module to let Python do this. While the module can do all of the basic functionality of reading and writing cells, VBA might have some features that OpenPyXL lacks.

Python has win32 modules (mostly written by a guy named Mark Hammond) which can interact with COM components and do PowerShell-like things, so you might also want to check that out.

But in general, I would recommend the Python route anyway unless everyone at the company already has VBA expertise and an existing codebase of VBA scripts.
 
Tom Nielson
Ranch Hand
Posts: 53
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very cool. I went ahead and ordered a copy on Amazon for my brother. I wouldn't mind getting one for myself.

I was a VBA developer for a few years before coding in Java, and I would rather encourage him to start scripting in something relevant and defining the future, rather than something that exists because of legacy. Python definitely seems to be hot right now and I may pick it up too.
 
Liar, liar, pants on fire! refreshing plug:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic