Change the icon of an Excel file
I want to change the icon of a single excel file. I searched in the file properties but there is no change icon.
The goal is to have different icons in relation to the types of Excel files for further clarity.
The icons used are free, meaning that I can use what I draw
If you have any info to help me I'm interested
Re: Change the icon of an Excel file
To my knowledge what you want to do is not feasible because the icon is linked to the type of file and not in his name.
A possible solution, create a folder and add a shortcut for each file, then each shortcut will be individually adjustable.
Re: Change the icon of an Excel file
1 - Create a desktop shortcut to your file (Right Click/new/shortcut).
2 - Right click on the shortcut then 'Properties' then 'change icon'
Re: Change the icon of an Excel file
the solution of the shortcut is not what I wanted (this is what I already use). It does not totally agree, is there any other solution
Re: Change the icon of an Excel file
You can test this procedure to place the module in the workbook "ThisWorkbook".
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessageA Lib "user32" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _
ByVal lParam As Long) As Long
Private Declare Function ExtractIconA Lib "shell32.dll" _
(ByVal hInst As Long, ByVal lpszExeFileName As String, _
ByVal nIconIndex As Long) As Long
Private Sub Workbook_Activate ()
Dim File As String
Dim x As Long
'Path and filename of the icon to display
File = "C:\folder\myfile.ico"
'Check if file exists
If Dir (File) = "" Then Exit Sub
x = ExtractIconA (0, file, 0)
SendMessageA FindWindow (vbNullString, Application. Caption), _
& H80, False, x
End Sub
Private Sub Workbook_Deactivate ()
Dim File As String
Dim x As Long
File = Application. Path & "\excel.exe"
x = ExtractIconA (0, file, 0)
SendMessageA FindWindow (vbNullString, Application. Caption), _
& H80, False, x
End Sub
Re: Change the icon of an Excel file
Hi everybody,
I've been using this tempalte for a while and runs properly. However I've been asked to be a little bit more 'seasonal' in my excel files and suggest me to put a pumpkin icon & 'Happy Halloween' for example. I can uplaod an icon from internet put it in C:\WINDOWS\system32 and that's it. However when my friends will open the file it will work only if they also have the .ico file. Is there a way to self contain the picture into the excel file ? Something like refering to the picture paste somewhere on the excel file or keep in a UserForm in vba?
Thansk for your answers.
Don Pablo