Excel Headings

chestera used Ask the Experts™

Is it possible to put a graphic in an Excell heading either 97 or 2000 eg a company logo.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006

Hello Chestera,

What heading do you mean? the Application caption?

Top Expert 2006

Found this


Subject: Re: Code for changing Excel icon
Date: 11/02/2000

Untested, but here is a message I saved on the topic:

'Mark Lundberg said
'Here's some code that will change the XL icon both
'for the Excel system menu (top left corner), and in
'the taskbar. I can't remember where I got the code
'from, but I think it was Stephen Bullen's. Seems likely,
'anyway <g>.

'Get the handle for a window
Declare Function wapiFindWindow Lib "user32" Alias "FindWindowA" _ (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long

'Extract an icon from a file
Declare Function wapiExtractIcon Lib "shell32.dll" Alias "ExtractIconA" _
(ByVal hInst As Long, ByVal lpszExeFileName As String, _
ByVal nIconIndex As Long) As Long

'Send a Windows message
Declare Function wapiSendMessage Lib "user32" Alias "SendMessageA" _ (ByVal
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _ ByVal lparam As
Long) As Long

'Windows message types
Public Const WM_SETICON = &H80
Sub changeicon()
    Dim sName As String
    sName = "C:\Test\example.ico"
    'Uncomment the next line to restore the standard Excel icon.     'sName
= "C:\Program Files\Microsoft Office97\Office\msoffice.exe"     Call
End Sub

Sub procSetIcon(sIconPath)

    Dim a As Long, ihWnd As Long, ihIcon As Long

    'Get the handle of the Excel window
    ihWnd = wapiFindWindow("XLMAIN", Application.Caption)

    'Get the icon from the source
    ihIcon = wapiExtractIcon(0, sIconPath, 0)

    '1 means invalid icon source, 0 means no icons in source
    If ihIcon > 1 Then

        'Set the big (32x32) and small (16x16) icons
        a = wapiSendMessage(ihWnd, WM_SETICON, True, ihIcon)
        a = wapiSendMessage(ihWnd, WM_SETICON, False, ihIcon)
    End If

End Sub

If it was a Stephen's site, you can go there with
http://www.BMSLtd.co.uk  then go to the Excel or other Excel related page.

Tom Ogilvy


not tested this



A page heading, I have no problems with text.

Top Expert 2006
Hello Chestera,

didn't know which header but here we go, you cannot put the Logo into the actual Header, but you can find a little more information about  putting it at the top of the spreadsheet, first page only, or all pages.

Actually if you had the logo converted to a font character you could use your own font in black in the actual header, but that is not something the casual user is likely to do.   There are several things lacking in Excel compared to Word, and headers is one of them




Thanks your help, you have just confirmed what I thought the situation was. I can cut and paste a logo onto the spreadsheet, would have been better to be able to cut and paste into a page Header, such is life.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial