如何在Excel中更改工作簿图标?

时间:2010-09-10 00:44:41

标签: excel winapi vba

我设法编写了一些代码来更改Excel应用程序图标。请参阅this post

作为后续操作,如何更改Excel应用程序图标正下方的图标?我也想更改工作簿图标。有任何想法吗?谢谢!

1 个答案:

答案 0 :(得分:0)

Dim hWndExcel As Long
Dim hWndDesk As Long
Dim hIcon As Long

//Get the main Excel window
hWndExcel = FindWindow("XLMAIN", Application.Caption)

//Find the desktop
hWndDesk = FindWindowEx(hWndExcel, 0, "XLDESK", vbNullString)

//Find the workbook window
WorkbookWindowhWnd = FindWindowEx(hWndDesk, 0, "EXCEL7", "TRAM Dev.xls")

/Get the icon handle
hIcon = ExtractIcon(0, "d:\tram.ico", 0)

//Set the big (32x32) and small (16x16) icons
SendMessage WorkbookWindowhWnd, WM_SETICON, 1, hIcon
SendMessage WorkbookWindowhWnd, WM_SETICON, 0, hIcon

Application.ScreenUpdating = True