Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Const WM_SETICON = &H80
Sub SetExcelIcon()
Dim lngXLHwnd As Long, lngIcon As Long, strIconPath As String
'Change this to a valid icon path on your network/drive
strIconPath = "C:Program FilesMicrosoft Visual StudioCommonGraphicsIconsFlagsFLGUK.ICO"
lngXLHwnd = FindWindow("XLMAIN", Application.Caption)
lngIcon = ExtractIcon(0, strIconPath, 0)
SendMessage lngXLHwnd, WM_SETICON, False, lngIcon
End Sub