ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
楼主: ldhyob

[原创]我的EXCEL宏文档打开程序

[复制链接]

TA的精华主题

TA的得分主题

发表于 2003-4-18 12:53 | 显示全部楼层
ldhyob兄: 请问你怎么实现: 当右键单击时,如何取消工具栏的(因为我是初学,请指教)?

TA的精华主题

TA的得分主题

发表于 2003-4-18 13:02 | 显示全部楼层
能不能公开代码?让我们学习学习。。。。

TA的精华主题

TA的得分主题

发表于 2003-4-18 13:11 | 显示全部楼层
为什么把下载的TXT文件改为EXE后,毒霸提示我有木马~~~~!?

TA的精华主题

TA的得分主题

 楼主| 发表于 2003-4-20 20:48 | 显示全部楼层
TO 南山下: myexcel.exe是启动程序,把你自己XLS、BMP文件放置于DATA子目录下即可。 TO 蓝天SKY: 取消工具栏的语句格式是: application.commandbars(XXX).enabled=false XXX是各系统工具栏的名称。 如果你需要这个XLS的源码,我发给你好了,告诉我你的邮箱。

TA的精华主题

TA的得分主题

发表于 2003-4-20 21:56 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2003-4-21 09:53 | 显示全部楼层
ldhyob兄: 好东西, 给我一个好吗? tcmzyh@sina.com

TA的精华主题

TA的得分主题

发表于 2003-4-21 12:53 | 显示全部楼层
ldhyob兄: 谢谢你!! FUN200@21CN.COM 谢谢!!

TA的精华主题

TA的得分主题

发表于 2003-4-22 08:16 | 显示全部楼层
给我发一个好吗? george.dai@sohu.com thank u !

TA的精华主题

TA的得分主题

发表于 2003-4-22 08:56 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
为什么不公开代码呢?省的ldhyob兄一个一个的发邮件 我的: wuhan_jlh@hotmai.com :)

TA的精华主题

TA的得分主题

 楼主| 发表于 2003-4-22 10:11 | 显示全部楼层
呵呵,因为代码很简陋,所以不敢公开了. 以上朋友已将文档发送过去了. 主要代码如下: '=========================== '程序名称:VBA应用程序模板 '代码:ldhyob '日期:2003年4月 '=========================== Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 Public Const GW_CHILD = 5 Public Const GW_HWNDNEXT = 2 Dim mnuSys As CommandBar '系统菜单条 Dim colVisualCommandBars As New Collection '用于各个工具条 Dim hwa As Long '用于工作簿窗口句柄 Sub SetCommandbars() '只留下系统菜单 Dim cmb As CommandBar Dim cmc As CommandBarControl Set mnuSys = Application.CommandBars("Worksheet Menu Bar") For Each cmb In Application.CommandBars '隐藏除系统菜单外的所有工具条 If cmb.Name <> "Worksheet Menu Bar" Then If cmb.Visible Then colVisualCommandBars.Add cmb, cmb.Name cmb.Visible = False '隐藏其它工具条 End If End If Next For Each cmc In mnuSys.Controls '隐藏系统菜单的各弹出菜单 cmc.Visible = False Next End Sub Sub RestoreCommandbars() Dim cmb As CommandBar For Each cmb In colVisualCommandBars cmb.Visible = True colVisualCommandBars.Remove cmb.Name Next End Sub Sub AddCustonCommands() Dim cmb As CommandBarControl Set cmb = AddCustomCommandBarPopup("系统(&S)") AddCustomCommandBarItem cmb, "退出系统(&X)", "ExitSys", False, True Set cmb = AddCustomCommandBarPopup("数据处理(&P)") AddCustomCommandBarItem cmb, "输入报表数据(&I)", "Hello", False, True AddCustomCommandBarItem cmb, "查看报表数据(&S)", "Hello", True, True AddCustomCommandBarItem cmb, "查看数据更新(&G)", "Hello", False, True AddCustomCommandBarItem cmb, "打印指标比率(&P)", "Hello", True, True Set cmb = AddCustomCommandBarPopup("系统维护(&P)") AddCustomCommandBarItem cmb, "修改用户(&I)", "Hello", False, True AddCustomCommandBarItem cmb, "修改表类(&S)", "Hello", False, True AddCustomCommandBarItem cmb, "修改其它(&G)", "Hello", False, True AddCustomCommandBarItem cmb, "模拟输入(&R)", "Hello", True, True Set cmb = AddCustomCommandBarPopup("帮助(&H)") AddCustomCommandBarItem cmb, "关于(&A)", "ShowAbout", False, True End Sub Sub RemoveCustonCommands() '恢复系统菜单的各弹出菜单 mnuSys.Reset End Sub Function AddCustomCommandBarPopup(Caption As String) As CommandBarControl Dim cmb As CommandBarControl Set cmb = mnuSys.Controls.Add(msoControlPopup) cmb.Caption = Caption cmb.Visible = True Set AddCustomCommandBarPopup = cmb End Function Sub AddCustomCommandBarItem(cmbc As CommandBarControl, _ Caption As String, Macro As String, NewGroup As Boolean, Enable As Boolean) Dim cbb As CommandBarButton Set cbb = cmbc.Controls.Add(msoControlButton) cbb.Caption = Caption cbb.OnAction = Macro cbb.BeginGroup = NewGroup cbb.Enabled = Enable End Sub Sub Initialize() Dim hicon, hWnd, hwnd2 As Long hicon = ExtractIcon(0, Mid(ThisWorkbook.Path, 1, Len(ThisWorkbook.Path) - 4) + "myexcel.exe", 0) '从myexcel.exe中取图标句柄 hwnd2 = gethw '获取工作簿窗口句柄 SendMessage hwnd2, WM_SETICON, True, hicon '更换工作簿窗口图标为hicon SendMessage hwnd2, WM_SETICON, False, hicon '刷新,否则图标不能立即得到更新 Application.ScreenUpdating = False SetCommandbars AddCustonCommands With Application .Caption = "公司业务报表处理系统 2003.04" With .Windows(1) .Caption = "" .WindowState = xlMaximized End With End With With Application .DisplayFormulaBar = False .DisplayStatusBar = False .CommandBars("System").Enabled = False .CommandBars("Document").Enabled = False .CommandBars("Toolbar List").Enabled = False .CommandBars("ply").Enabled = False End With Application.ScreenUpdating = True hWnd = FindWindow(vbNullString, "公司业务报表处理系统 2003.04") '获取窗口句柄 SendMessage hWnd, WM_SETICON, 1, hicon '更换主窗口图标 If Dir(ThisWorkbook.Path + "\test.bmp") <> "" Then Worksheets("sheet1").Image1.Left = (Application.Width - Worksheets("sheet1").Image1.Width) / 2 - 25 Worksheets("sheet1").Image1.Top = (Application.Height - Worksheets("sheet1").Image1.Height) / 2 - 30 Worksheets("sheet1").Image1.Visible = False Worksheets("sheet1").Image1.Picture = LoadPicture(ThisWorkbook.Path + "\test.bmp") End If Application.OnKey "%{F11}", "InsertProc" '屏蔽ALT+F11 VBA窗口键 End Sub Sub Restore() Application.ScreenUpdating = False Application.Caption = "Microsoft Excel" RemoveCustonCommands RestoreCommandbars With Application .DisplayFormulaBar = True .DisplayStatusBar = True End With Application.ScreenUpdating = True End Sub Sub ExitSys() Application.Quit End Sub Sub InsertProc() End Sub Private Function gethw() Dim TitleToFind As String, ClassToFind As String If InStr(1, ThisWorkbook.Name, ".") = 0 Then TitleToFind = ThisWorkbook.Name Else TitleToFind = Left(ThisWorkbook.Name, InStr(1, ThisWorkbook.Name, ".") - 1) End If ClassToFind = "EXCEL7" Call FindWindowLike(GetDesktopWindow(), TitleToFind + ".xls", ClassToFind) gethw = hwa End Function Private Function FindWindowLike(ByVal hWndStart As Long, _ WindowText As String, _ Classname As String) As Long Dim hw As Long Dim sWindowText As String Dim sClassname As String Dim r As Long Static level As Integer If level = 0 Then If hWndStart = 0 Then hWndStart = GetDesktopWindow() End If level = level + 1 hw = GetWindow(hWndStart, GW_CHILD) Do Until hw = 0 Call FindWindowLike(hw, WindowText, Classname) sWindowText = Space$(255) r = GetWindowText(hw, sWindowText, 255) sWindowText = Left(sWindowText, r) sClassname = Space$(255) r = GetClassName(hw, sClassname, 255) sClassname = Left(sClassname, r) If (sWindowText Like WindowText) And _ (sClassname Like Classname) Then hwa = hw Exit Function End If hw = GetWindow(hw, GW_HWNDNEXT) Loop level = level - 1 End Function
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-5-22 04:09 , Processed in 1.038624 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表