注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

专修培训

——专业计算机培训机构

 
 
 

日志

 
 

自定义Excel工作薄图标和标题  

2010-12-28 00:17:54|  分类: 学习 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

首先,在要打开的Excel工作薄所在的文件夹下建立一个ICO图标文件,再在对象ThisWorkbook中编辑以下的代码:
' 对象ThisWorkbook的代码,目的是改变Excel标题栏的图标和标题
' 借鉴于chijanzen大师(微软MVP)的原创代码

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SetFocus Lib "user32" (ByVal hWnd As Long) As Long
Private Declare 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 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

Function hWndForm() As Long
hWndForm = FindWindow(vbNullString, Application.Caption)
End Function

Private Sub Workbook_Open()
Dim IStyle As Long, hIcon As Long
hIcon = ExtractIcon(0, ActiveWorkbook.path & "\Ico.ico", 0) '选择一个ICO图标,将"Ico.ico"替换掉
SendMessage hWndForm, WM_SETICON, True, hIcon
SendMessage hWndForm, WM_SETICON, False, hIcon
DrawMenuBar hWndForm
SetFocus hWndForm
Application.Caption = "GaoYuexun的表格:" '自定义标题栏,文字可替换
End Sub

  评论这张
 
阅读(254)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017