更改 Excel 的徽标

更改 Excel 的徽标

我想更改徽标。经过大量研究,我发现了这一点 -

Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Private Declare PtrSafe Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long

Private Const WM_SETICON = &H80

Sub ChangeExcelIcon()
Dim hIcon As Long
hIcon = ExtractIcon(0, "C:\Users\Rokon\Desktop\New folder\ERP_ICON.ico", 0)
SendMessage Application.hWnd, WM_SETICON, False, hIcon
End Sub

Sub ResetExcelIcon()
Dim hIcon As Long
hIcon = ExtractIcon(0, Application.Path & "\excel.exe", 0)
SendMessage Application.hWnd, WM_SETICON, False, hIcon
End Sub

一切都很好。它成功更改了徽标。但这要求我必须将图标放在文件管理器的空间中。但我希望将该徽标插入我的 excel 表中,然后将图片链接到我的 VBA 代码,这样除了该 excel 文件之外,我不需要任何其他文件。

希望你能理解。

相关内容