Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Nov 2001
    Location
    MI, USA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing the default TitleBar Icon (XL 2000)

    Hi,

    How would I change the default icon in the xl titlebar? I got the following from somewhere, but when I searched in the archives of this list, it didn't turn up. My apologies to the originator.

    Sub ReplaceTitleBar()
    'Replace Excel's default titlebar
    'The Application.Caption command makes it possible to replace the default excel caption
    '(Microsoft Excel) with your own. (i.e. your application name). The Windows(1).Caption
    'command is the command Excel uses to display the name of the active workbook.
    'I often replace this to view not only the current files name, but it's path as well.

    ' Place the current files path and filename in the titlebar:
    Windows(1).Caption = (ActiveWorkbook.FullName)
    ' Place your own application name in the titlebar:
    Application.Caption = ("Your text here")
    End Sub

    I don't want to change the default icon for XL in general, only for this particular workbook, using "xyz.ico", and not one extracted from a DLL or EXE file. Ideally, I'd want to see my special icon, when viewed in Windows Xplorer or when opened in XL, even when the window is deactivated/minimized.

    Out of curiousity, would it be also possible to use an ANI or CUR file? Better yet, I think it would be cool if one could use a custom animated bmp file that would spin or animate while a macro or function was running, similar to the Internet Explorer or Holodeck 3 logo that <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15> whenever a file is being downloaded. Any ideas or examples would be much appreciated.

    Thanks in advance

    AJF

    P.S. In any case, I thot this list might be interested in the following code for extracting & using an icon from an EXE file, as follows;
    xlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxlxl xlxlxlxlxlxlxlxlxlxlxlxlxllxl
    (Thanks to Paul Wight at Microsoft Excel Developers List)

    Code to change Excel icon... (in this case to the Notepad icon)

    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

    Sub ChangeXLIcon()
    Dim h32NewIcon As Long
    Dim h32WndXLMAIN As Long
    h32NewIcon = ExtractIcon32(0, "Notepad.exe", 0)
    h32WndXLMAIN = GetActiveWindow32()
    SendMessage32 h32WndXLMAIN, &H80, 1, h32NewIcon 'Icon big
    SendMessage32 h32WndXLMAIN, &H80, 0, h32NewIcon 'Icon small
    End Sub

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing the default TitleBar Icon (XL 2000)

    I believe that the Icon that displays in File Explorer and in the File Open Dialog for a data file is the Icon of the program that will be used to open the file. There are a couple of ways that you might be able to change this:

    1- Create a shortcut to the program file and in the shortcut properties change the Icon. Then change the file extension on the data file and assign the shortcut as the program to open that file extension.

    2- Make a copy of the Excel exe file, change the file name, change the Icon for the changed program file, and then change the file type of the data file as above and assign the copy of the exe file as the program to open the new file type.
    Legare Coleman

  3. #3
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Changing the default TitleBar Icon (XL 2000)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> AJF

    OK I knew all about the caption and the Window name, but the icon, that little Excel icon all the way to the left of the Titlebar is something special.

    I think it has to do with the application itself, the Excel.exe, and possibly the registry. I know you can pick what ever icon you want for the Excel workbook, but I am not sure if that would change the titlebar icon.

    I'll test it for you and then get back to you with an answer.

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  4. #4
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Changing the default TitleBar Icon (XL 2000)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> AJF

    Sorry I missed the part underneath. Well that code does change the icon of the active window to whatever you want it to be, so what is your question again? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Try the code and it persists until you close Excel, but it will not be saved.

    neat trick.

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  5. #5
    Lounger
    Join Date
    Nov 2001
    Location
    MI, USA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing the default TitleBar Icon (XL 2000)

    Yeah, that code will change the icon, in this case to NOTEPAD. But the codes I was given was written to extract the icon from another EXE file. I tried fiddling with the codes to just use "XYZ.ico", but that doesn't work--this error or that.

    Beyond the static icon, I was also wondering if it would be possible to use an animated icon.

    Perhaps another tactic would be to eliminate the XL icon on this workbook, and in its place, insert a small graphics window, a la, IE's right-hand animation.

    I thot it would be an extra hit, if I eliminated any visual clues to XL <img src=/S/dragon.gif border=0 alt=dragon width=17 height=15> as the application, since all of the toolbars will be hidden except for one custom toolbar. If all else fails, I could use Legare's suggestion and make a copy of Excel.exe and change its icon etc and the "Opens With" properties and place that on the 6 or 8 computers that will be running this worksheet almost exclusively--for work at least. Actually, for those work computers, I might just change the icon for XL itself and not bother with the copy.

    Thanks
    AJF

  6. #6
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Changing the default TitleBar Icon (XL 2000)

    AJF

    Yes this code uses Windows API to extract the icon, and it will work as such. Now maybe you can exclude the API and just say <font color=red> h32NewIcon =XYZ.ICO </font color=red> You have to test this one.

    But since you really want to eliminate any Excel references that is going tom take a lot of work, since you have many items to worry about, like the little icon on the standard toolbar that works like the shortcut menu. You can disable that, but the point is how many other things do you have to worry about.

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  7. #7
    Lounger
    Join Date
    Nov 2001
    Location
    MI, USA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing the default TitleBar Icon (XL 2000)

    Wassim, I don't want to eliminate any XL references, I just wanted to modify the obvious visual cues, at least as far as when opening it. I tried several code combos to substitute the icon name and path, but keep getting errors. I guess the send message 32 wants a "Long" variable. I'll keep doing trial/error time permitting, until I either find something or give up. Thanks

    AJF

Posting Permissions

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