How to upgrade an Excel Addin with many Excel instances already running…

Riddle of the day:

How do you convince a trader to close multiple running Excel instances with about 20 different spreadsheets open so that you can upgrade the buggy Excel addin which you wrote and is screwing up their trading?

The answer is, you can’t…

So here is a reliable alternative that both works and increases the traders confidence in your abilities.

(1) Deploy the new addin to a different folder than the existing addin.

(2) Delete any registry key that references your addin in the following user hives:

HKEY_CURRENT_USER\Software\Microsoft\Office\xx.0\Excel\Options

HKEY_CURRENT_USER\Software\Microsoft\Office\xx.0\Excel\Add-in Manager

(3) From the tools->Add-In menu, add your new addin from a brand new instance of Excel

(4) Once you exit the new instance of Excel, the registry key for loading the new Addin is created with a reference to the new version

This way you can upgrade your addin to a new version without disrupting the existing workflow of the trader.  The best part is that as they close each instance of excel, the older version is never loaded again, ever.

 

Posted in Uncategorized | Leave a comment

Creating a VBA Variant with type “Missing”

How do you test an Excel VBA function that takes lots of optional parameters without making a lot of calls to the same function?

Instead of:

If NumberOfArguments = 1 Then

MyFunction varg1

ElseIf NumberOfArguments = 2 Then

MyFunction varg1, varg2

Do this:

Dim varg1, varg2 As Variant

varg1 = “Some Value”

varg2 = GetMissing()

MyFunction varg1, varg2

Private Function GetMissing(Optional var1 As Variant) As Variant

GetMissingAsVariant = var1

End Function

 

 

Posted in Excel VBA | Leave a comment