开发者

How can I change the workbook icon in Excel?

开发者 https://www.devze.com 2023-01-15 07:32 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消