title: Changing Excel Icon doesn't work when another workbook is opened
body: <p>I am using the following code, which nicely changes the Excel icon to my own icon.</p>
  
  <p>It works perfectly as far as I open the workbook by itself BUT, as soon as another workbook is already opened, the code doesn't seem to have any effect any longer.
  It only works if Excel is completely closed, then I open the workbook with the code.
  As soon as I open another workbook, change from one workbook to another, etc, it not longer works.</p>
  
  <p>I am using Windows 7, Excel 2007.</p>
  
  <p>I hope someone can help.
  Thanks</p>
  
  <pre><code>Private Sub Workbook_Open()    
      changeXLIcon "D:/myBOOK/IQS.ico"
  End Sub
  
  Private Sub Workbook_WindowActivate(ByVal Wn As Window)
      changeXLIcon "D:/myBOOK/IQS.ico"
  End Sub
  
  Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
      changeXLIcon "Excel.exe"
  End Sub
  
  
  Declare Function GetActiveWindow32 Lib "USER32" Alias "GetActiveWindow" () As Integer
  Declare Function SendMessage32 Lib "USER32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
  
  Public Sub changeXLIcon(iconname As String)
  
      Dim Icon&amp;
  
  
      Icon = ExtractIcon32(0, iconname, 0)
      SendMessage32 GetActiveWindow32(), &amp;H80, 1, Icon '&lt; 1 = big Icon
      SendMessage32 GetActiveWindow32(), &amp;H80, 0, Icon '&lt; 0 = small Icon
  
  
  End Sub
  </code></pre>