Hi All,
I have an addin which update from a server but I only want to perform this the first time the user opens Excel.
So far I've achieved this by using this well known function to count the number of instances open.

In a scenario where there is One Instance containing One Workbook, containing One Worksheet:
It gives the expected result of 1 in earlier versions of Excel, but in Excel 365 32bit it returns 3

I guess this has something to do with Excel moving to SDI (?) but does of a better way to achieve this?

Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function FindWindowEx Lib "user32" Alias _
  "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Function ExcelInstances() As Long
    Dim hWndDesk As Long
    Dim hWndXL As Long

    'Get a handle to the desktop
    hWndDesk = GetDesktopWindow

    Do
        'Get the next Excel window
        hWndXL = FindWindowEx(GetDesktopWindow, hWndXL, _
          "XLMAIN", vbNullString)

        'If we got one, increment the count
        If hWndXL > 0 Then
            ExcelInstances = ExcelInstances + 1
        End If

        'Loop until we've found them all
    Loop Until hWndXL = 0
End Function