Thursday, 23 June 2016

Why clean Excel VBA macros?


Visual Basic for Applications (VBA) is a programming language built into most Microsoft Office applications. It first appeared in 1993. Although new VBA properties and methods are constantly being added to support innovations in Office, the Visual Basic Editor (VBE) and VBA's inner workings haven't changed much over the last 2 decades in order to ensure consistency and compatibility in the programming model across releases. 
Hardware in the mid-90s was pretty slow compared to computers nowadays, so VBA had to rely on an internal performance cache in order to deliver an acceptable user experience. 
Unfortunately, VBA code doesn't properly clean-up after itself, so lots of junk gets left behind in performance caches during extensive editing of VBA projects. Not only does this increase the file size, but it may lead to odd behaviour of your program at runtime or slow loading.

If Add-ins or workbook macros are run across several versions of Office, stability issues are likely to be experienced with any uncleaned VBA project. The problems are triggered by compiled macro code stored in version dependent performance caches.

These redundant code caches can even provide a peak at earlier versions of your code. A forensic investigator can travel back in time and read bits and pieces from code you compiled during VBA code revisions. So, if you really want to delete any sensitive code from your macro-enabled workbooks, you should distribute only cleaned VBA files.
If you plan to share a copy of a macro-enabled Office file or template (workbook, document, presentation etc) you should be aware that the username used by the macro author may be stored inside the redundant compiled code caches of the VBA project.

Depending on how private you want your coding work to be, you may want to remove this hidden information by cleaning the VBA project in macro-enabled files, as it can reveal sensitive details about your company or yourself to the public.

THE WORKAROUND
Ribbon Commander offers the .CleanVBAProject method, which can remove all code garbage from any macro-enabled or binary workbook and Add-ins instantly. 
The Ribbon Commander VBA cleaner removes all redundant caches from closed files, so VBE doesn't get a chance to replace the information. 
Cleaned files are smaller in size. Nowadays files are moved between desktops and the cloud more frequently than ever before. On an enterprise level, smaller files translate into decreased costs for online storage / bandwidth and faster backups or downloads. 
For years the 'golden' standard for Excel VBA code cleaning has been module export - import.  Ribbon Commander aims to raise the bar by offering several productivity advantages for VBA developers. 
  • Ribbon Commander's VBA Project code cleaner supports both 32 & 64 bit versions of Office/Excel.
  • The CleanVBAProject method does NOT open files in Excel. This translates to significant time savings, as massive workbooks may require even minutes to open and save.
  • Multiple closed files can be cleaned very fast by Ribbon Commander. Check if your files are already clean using the .isVBAProjectClean property.
  • Traditional cleaning involves exporting all VBA components to text files on disc. This a loophole for the security minded, as these text files can be undeleted easily by file recovery software.
  • Ribbon Commander's Code Cleaner can read and clean both unlocked & locked VBA projects. 
  • End users can clean 3rd party protected Add-ins, when stability issues are experienced during loading or running code. Locked VBA projects are not unprotected under any circumstances.
  • Ribbon Commander's Code Cleaner can clean closed macro-enabled (.xlsm), binary (.xlsb) workbooks, templates (.xltm) & Add-ins (.xlam) or any macro-enabled Office file (PowerPoint presentations & Word documents).
  • Ribbon Commander's Code Cleaner can remove the full path to MSForms.exd from the VBA performance cache, which contains the developer's username in the format shown below:
    C:\Users\james07\AppData\Local\Temp\VBE\MSForms.exd
Reclaim existing storage space on desktop PCs and servers by replacing large macro-enabled Microsoft Office files with smaller versions. Slow storage growth as new files are added. Test for yourself: files shown are available at Bruce's Mcpherson blog:Desktop Liberation

No comments:

Post a Comment