Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Apr 2003
    Hampshire, United Kingdom
    Thanked 0 Times in 0 Posts

    Application Icon (2002 (Office XP))

    In Access, you can change the application icon. Can the same be done in Excel (and if so, how)?

    Thanks in advance
    If at first you do succeed, you've probably missed something.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Application Icon (2002 (Office XP))

    There is no built-in way to change the Excel application icon. It takes Windows API programming to do so. See here for a list of newsgroup posts about this subject.

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Pittsburgh, Pennsylvania, USA
    Thanked 342 Times in 335 Posts

    Re: Application Icon (2002 (Office XP))

    Just curious.
    Looking thru these posts, it seems we can change and restore the icon on the TitleBar.

    None of the methods change the icon on the MenuBar.

    There was one comment by Excel MVP Rob Bovey that this was not possible.

    Is this the consensus:
    Caption icon changed with API,
    Menu bar icon not possible?


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Application Icon (2002 (Office XP))

    I haven't tried it, but who am I to doubt Rob Bovey?

  5. #5
    Bronze Lounger
    Join Date
    Nov 2001
    Arlington, Virginia, USA
    Thanked 3 Times in 3 Posts

    Re: Application Icon (2002 (Office XP))

    Here is a simple example of how to do this in Excel 2002 using Windows API functions:

    Option Explicit

    Private Declare Function LoadImage Lib "user32" _
    Alias "LoadImageA" _
    (ByVal hInst As Long, _
    ByVal lpsz As String, _
    ByVal un1 As Long, _
    ByVal n1 As Long, _
    ByVal n2 As Long, _
    ByVal un2 As Long) _
    As Long

    Private Declare Function SendMessage Lib "user32" _
    Alias "SendMessageA" _
    (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) _
    As Long

    Const WM_GETICON = &H7F
    Const WM_SETICON = &H80
    Const ICON_SMALL = 0
    Const ICON_BIG = 1

    ' LoadImage() image types:
    Const IMAGE_BITMAP = 0
    Const IMAGE_ICON = 1
    Const IMAGE_CURSOR = 2

    ' LoadImage() flags:
    Const LR_LOADFROMFILE = &H10

    Public Function LoadAppIcon(ByRef IconPath As String) As Boolean

    Dim hIcon As Long
    Dim hwnd As Long

    hIcon = LoadImage(0&, IconPath, IMAGE_ICON, 16, 16, LR_LOADFROMFILE)

    ' Note: App hwnd property available only in XL 2002 or later
    ' If using earlier version use FindWindow API function
    hwnd = Application.hwnd

    If hIcon <> 0 Then
    Call SendMessage(hwnd, WM_SETICON, 0, ByVal hIcon)
    LoadAppIcon = True
    End If

    End Function

    Example that loads Access icon in Excel application window:

    Sub TestLoadAppIcon()
    LoadAppIcon "C:AccessIconsA2K.ico"
    End Sub

    The icon will appear in application title bar & Windows taskbar (see attached screen shot). As noted, don't know if it is possible to alter Excel icon that appears in menu bar. NOTE: If using XL 2K or earlier, there is no Excel Application hwnd property available. In that case, you'd have to use FindWindow API to get application window handle. For example see MSKB article 258511:

    HOWTO: Obtain the Window Handle for an Office Automation Server


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts