How can I change the workbook icon in Excel?
I managed to write some code to change the Excel application icon. See this post.
As a follow up how can I change the icon that sits directly below the Excel application icon?开发者_开发问答 I want to change the workbook icon as well. Any ideas? Thanks!
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
精彩评论