VBA in New Versions of Excel - vba

Here is a question for my Father. He has been using VBA in Excel for more than two decades going from Excel 5 to this day where he is using Excel 2002.
As he has used VBA in Excel for so long, making extensive use of the ability to record macros, he has continued to invest in Excel as it has been rather stable (in terms of its VBA functionality) across each version. Now, he is considering upgrading to a newer version of Excel, however I have read reviews that Microsoft completely botched their VBA interpreter in Excel 2007, as scripts that used to work in Excel 2003 or earlier would become painfully slow or stop functioning altogether. Then looking into Excel 2010, I've read that a lot of the issues with Excel 2007 "haven't been fixed". As I am not sure as to the credibility of these reviews, which I have read I am posing this question For all those folks out that are currently making heavy use of VBA in Excel:
Would it be advisable for someone who has a great deal of time and work invested in VBA from Excel 2002 or earlier to upgrade to either Excel 2003, 2007 or 2010?

There were several performance issues with Excel 2007 VBA. Many of these were fixed in Excel 2007 SP1. There were also a number of macro recorder problems with Charts and Shapes.
My personal recommendation would be Excel 2010: the VBA performance and Macro recorder issues have been fixed and I find the overall stability of Excel 2010 to be superior to most recent versions (but YMMV).
Migrating from Excel 2002 to 2007 or 2010 will involve learning to use the ribbon: some people like it and some people hate it, but it certainly will require effort for a long-term Excel user. Note that the VBA IDE has not changed.

If your father survived the migration to Excel 97, the switch to 2007 or 2010 will feel like a cakewalk. Other than the new GUI, the changes are of the more-better variety. I haven't run into any compatibility issues including the big jump from 97 to 2003.
To get up to date, I'd recommend John Green et al's Excel 2007 VBA Programmer's reference.

Most of the VBA/Excel programs that I developed in Excel 2003 work just fine in 2007 and newer without modification (It seems like I remember most issues being chart related). Of course it's possible that at least some of his recorded macros or hand coded VBA will not work in Excel 2007 and newer. However with a little debugging the old code can likely be converted without too much headache (search the line that errors and you will likely find out how to rewrite the line).
There are free add-ins such as UBitMenu and others to bring back the old style menu menu.
I wrote a benchmark for Excel VBA earlier this year that contains 6 different performance tests. The results submitted by 373 people so far clearly show that excel 2007 is the slowest of all versions. Among Excel 2003, 2007, 2003, 2002, Excel 2010 performs best on most tests followed by Excel 2003. Between 2010 and 2003 the composite results are fairly close, but the individual benchmark tests show that Excel 2003 is much faster at displaying data on a chart while 2010 is faster with complex VBA based calculations. The complete results from the benchmark are located at http://exceltrader.net/et2/benchMark.php.

Related

Libre Office Calc Vs Excel

My company will be changing from Excel to Libre Office Calc. I have built up a collection of Excel VBA Macros (especially screen scrape macros). Will my Macros work without changes? Anybody else that has made the change, how do you make the change smoothly?
Possible already answered by Rubber Duck https://stackoverflow.com/a/24749320/7326037
From LibreOffice's online help file:
With a few exceptions, Microsoft Office and LibreOffice cannot run the
same macro code. Microsoft Office uses VBA (Visual Basic for
Applications) code, and LibreOffice uses Basic code based on the
LibreOffice API (Application Program Interface) environment. Although
the programming language is the same, the objects and methods are
different.
The most recent versions of LibreOffice can run some Excel Visual
Basic scripts if you enable this feature at LibreOffice -
PreferencesTools - Options - Load/Save - VBA Properties. In reality,
you would most likely need to sit down with the LibreOffice API and
rewrite the functionality.
This post also suggests that at parts of the VBA macros will work but will require a bit of manual migration.
https://ask.libreoffice.org/en/question/6621/import-ms-word-macros/?answer=6982#post-id-6982
In ODF/ODS files you have to enable VBA support at the beginning of the macro, otherwise it expects LO-Basic:
Option VBASupport 1
Option Compatible
Ultimately, you're probably going to have to go through each one and check that it functions correctly.
In most cases this won't work without converting the macros from VBA to Libre Office Basic. You will need to rewrite them and test them before you perform the switch to Libre Office to make a smooth switch.

VBA codes developed in Excel 2003

I just need to ask to what degree Macros developed in Excel 2003 are compatible with Excel 2010 and 2013?
I would tend to think that there would be some issues, but from your experience, what percentage of macros developed in Excel 2003 can work in Excel 2010/2013?
The issue you are going to have is with 32/64 bit compatibility. Office 2003 is 32-bit only; starting with Office 2007, some versions are 64-bit.
Microsoft has a pretty good writeup of the issues on this page.
You should do some online searches for VBA features that were "deprecated" after Excel 2003. The single major feature that no longer works is Application.FileSearch
Just from msdn.microsoft.com:
Excel 2010 Object Model Changes Since Earlier Versions
What's New in Excel 2010
New Objects, Collections, and Enumerations_Excel.Dev
New Members and Constants_Excel.Dev
Tables of VBA Object Model Changes
VBA Object Model Changes
Word 2010 Object Model Changes Since Earlier Versions
What's new for VBA developers in Project 2013
And so on ...

How can I easily tell if my Excel 2007 code will work in earlier Excel versions?

I recorded a macro in Excel 2007 which used TintAndShade and PatternTintAndShade. Unknown to me, these two functions are not supported in earlier Excel versions but thanks to StackOverflow, I got a workaround.
Or so I thought. There are (apparently) other functions not supported by 2003. I say "apparently" because I do not have access to Excel 2003 but a colleague has told me that the macro does not work. I started asking him to tell me where the macro fails and then solving that (and iterating) but this is a slow process.
Is there an easier way? Is there e.g. a list of new commands in Excel 2007 or a simple compatibility check?
As a coincidence, I came across this which might help: http://blogs.msdn.com/b/eric_carter/archive/2009/03/19/object-model-changes-for-developers-between-excel-2003-and-excel-2007.aspx
There is also a page on MSDN for Excel 2010 which although not directly relevant may also help: http://msdn.microsoft.com/en-us/library/ee836187.aspx
No, not really and I doubt that there is a fully compiled list of object changes.
The best solution would be to develop in 2003, there are very few objects in 2003 that aren't in later versions - filesearch is the only one I can think of off the top of my head. However there are loads of things in '07 that aren't available in earlier versions, particularly notable are the new functions included in '07.
Do you really have no way of developing in '03 can't you install it? There isn't really a foolproof way of ensuring that your workbook will work correctly in earlier versions of Excel unless it was developed in an earlier version (or it's really simple)

Migrating from VBA Excel 2003

I have a series of big excel files that work like a program, but I hate beeing tied up (stuck in VBA for excel 2003), so...
Whats the best way to implement a gui over a excel vba program (office 2003)? (are there any tools for that... I want to move away from the office suite, but still have it in the background)
Or what's the easiest alternative for migrating this code to a more open language.
Any ideias?
Have you looked at VSTO?
Resolver One is a Python spreadsheet system with strong support for importing from MS Excel. It's often used for the situation you describe.

Integration with Office 2007 VBA and Visual SourceSafe

I'm wondering if there's a way to manage VBA code authored in Excel 2007 using Visual SourceSafe? Office XP and 2000 apparently had 'developer additions' that supported this (e.g. http://msdn.microsoft.com/en-us/library/aa164419(office.10).aspx). Is this support missing in Office 2007?
The Office XP VSS addin worked fine in Excel 2007 last time I tried it (been a couple of years). It's really a VBA addin, and VBA hasn't changed much since Excel 2000 (eg, registered addins work across versions). You might need an MSDN subscription to download it, though- that's where I got it.