PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Change Excel Icon-VBForums
Results 1 to 10 of 10

Thread: Change Excel Icon

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Posts
    439

    Change Excel Icon

    How do you change the excel Icon? I've been searching, and can't seem to find anything "that I understand". I found one that changes the Icon when the Workbook is open but only on the Bottom Explorer Bar. Don't understand why you would want to do that, but..
    So..
    1. Can you change the icon from Workbook to Workbook?
    2. How do you change the Icon's for All Files?
    Attached Images Attached Images    

  2. #2
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,697

    Re: Change Excel Icon

    My code to change all opened Excel workbook icons:
    http://www.vbforums.com/showpost.php...04&postcount=4


    If you want to you can change it to change specific workbooks to specific icons. Just need to know the filenames as they appear int he window caption bar which FindWindow can search against.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,998

    Re: Change Excel Icon

    Place this in a module and run ReplaceIcon

    vb Code:
    1. Option Explicit
    2.  
    3. Declare Function SendMessage32 Lib "USER32" Alias "SendMessageA" _
    4. (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal _
    5. lParam As Long) As Long
    6.  
    7. Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias "ExtractIconA" _
    8. (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex _
    9. As Long) As Long
    10.  
    11. Declare Function GetActiveWindow32 Lib "USER32" Alias "GetActiveWindow" _
    12. () As Integer
    13.  
    14. Sub ReplaceIcon()
    15.     Dim Icon As String
    16.     Const NewIcon$ = "Notepad.exe"
    17.    
    18.     '~~> Getting the icon from windows calculator
    19.     '~~> similarly you can extract the icon from any exe
    20.     '~~> if the application is not present in windows path
    21.     '~~> then give complete path and file name
    22.     Icon = ExtractIcon32(0, "Calc.exe", 0)
    23.     '~~> you can use 1 for big icon
    24.     SendMessage32 GetActiveWindow32(), &H80, 1, Icon
    25.     '~~> and 0 for small icon
    26.     SendMessage32 GetActiveWindow32(), &H80, 0, Icon
    27. End Sub

    Edit: Speedy Rob beat me to it !!!!!
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - 2015 IMP Links : Acceptable Use Policy, FAQ
    MyGear:
    OMEN by HP - 15-ce073tx with Win10+Office 2013. || Mac Book Pro (10.6.8) with Office 2011

  4. #4
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,697

    Re: Change Excel Icon

    That will only change the active window. Mine will change all Excel windows even if they are minimized
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,998

    Re: Change Excel Icon

    Yeah I realized that after I posted and saw your post
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - 2015 IMP Links : Acceptable Use Policy, FAQ
    MyGear:
    OMEN by HP - 15-ce073tx with Win10+Office 2013. || Mac Book Pro (10.6.8) with Office 2011

  6. #6
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,697

    Re: Change Excel Icon

    See its a problem with GetActiveWindow32 as it can not return an active window outside of the calling thread. If the active window is some other instance of Excel then the call will return Null.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Posts
    439

    Re: Change Excel Icon

    Just from Reading your posts I gather it is the toolbar icon that changes upon opening of the document. Am I correct in that?

    I mean in My Documents the Excel Workbook/s sitting there and they all look the same. I'm wanting for some of them have different Icon's. Possible? IF not, I would at least like to change all of them to one of the attached Icon's.

  8. #8
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,697

    Re: Change Excel Icon

    Oh you want to change the Associated Icon in Explorer. That is something totally different.
    You can change individule icons for folders but not individule icons for files.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Posts
    439

    Re: Change Excel Icon

    Alright can you change the Associated Excel File Icon? If so how?
    I got this idea from a Program I downloaded from Cnet. It was a Project manager program made by someone, and you have a certain number of days till you have to register it. It's on my other computer, but it is Excel, and it's Icon is different than all the other excel files. Maybe I should be asking how you make an excel file not an excel file but like .AXL or something.

  10. #10
    New Member
    Join Date
    Aug 2019
    Posts
    2

    Re: Change Excel Icon

    Quote Originally Posted by Siddharth Rout View Post
    Place this in a module and run ReplaceIcon

    vb Code:
    1. Option Explicit
    2.  
    3. Declare Function SendMessage32 Lib "USER32" Alias "SendMessageA" _
    4. (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal _
    5. lParam As Long) As Long
    6.  
    7. Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias "ExtractIconA" _
    8. (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex _
    9. As Long) As Long
    10.  
    11. Declare Function GetActiveWindow32 Lib "USER32" Alias "GetActiveWindow" _
    12. () As Integer
    13.  
    14. Sub ReplaceIcon()
    15.     Dim Icon As String
    16.     Const NewIcon$ = "Notepad.exe"
    17.    
    18.     '~~> Getting the icon from windows calculator
    19.     '~~> similarly you can extract the icon from any exe
    20.     '~~> if the application is not present in windows path
    21.     '~~> then give complete path and file name
    22.     Icon = ExtractIcon32(0, "Calc.exe", 0)
    23.     '~~> you can use 1 for big icon
    24.     SendMessage32 GetActiveWindow32(), &H80, 1, Icon
    25.     '~~> and 0 for small icon
    26.     SendMessage32 GetActiveWindow32(), &H80, 0, Icon
    27. End Sub

    Edit: Speedy Rob beat me to it !!!!!
    How do I adjust the Icon size?

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width