excel 宏 VBA 填充背景色

intellectual1 2011-03-18 03:32:36
A B C D E F
1 Cc12 Cc13 Cc14 Cc15 Cc16
2 Cc13 背景色
3 Cc15 背景色 背景色 背景色

需要A列的所有单元格同B1,C1,D1,E1,F1比较。
例如B1单元格(数据是Cc12) 小于A2(Cc13),即12<13.
所以B2单元格填充背景色。
其它比较下来小于A列的所有单元格都填充上背景色。
请教高人!
excel 宏 VBA 填充背景色

...全文
472 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
王向飞 2011-03-18
  • 打赏
  • 举报
回复
 
主要还是几个函数的问题

If Range( "h4 ").Value > 0.01 And Range( "h4 ").Value < 0.02 Then
x = Range( "h4 ").Value - 0.01
Range( "c4 ").Value = Int((1 - Range(h4).Value - Range( "g4 ").Value) * Range( "b4 ").Value)
Range("A1:A6").Interior.Color = RGB(200,160,35)
王向飞 2011-03-18
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20070821/07/985327ac-ff56-40d8-adec-a45897317a36.html

http://office.microsoft.com/zh-cn/excel-help/HA001136627.aspx

我感觉这俩一结合就差不多了,你比我聪明你肯定能看懂

我觉得我都快看懂了
快溜 2011-03-18
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 wxf163 的回复:]
据我观察没人会

或许高手懒得出手,多顶顶帖吧
[/Quote]
你是间谍啊,就在坛子里观察动向。。。
王向飞 2011-03-18
  • 打赏
  • 举报
回复
据我观察没人会

或许高手懒得出手,多顶顶帖吧
AcHerat 2011-03-18
  • 打赏
  • 举报
回复
excel 宏 不会。。。
intellectual1 2011-03-18
  • 打赏
  • 举报
回复
我要写excel 宏,不是sql。
对不起,没有说清楚。
intellectual1 2011-03-18
  • 打赏
  • 举报
回复
是一张excel 表
数据如下,直接复制到excle中。
谁会写宏?
CC12 CC13 CC14 CC15 CC16
CC13 背景色
CC15 背景色 背景色 背景色
Rotel-刘志东 2011-03-18
  • 打赏
  • 举报
回复
发错地方了。
王向飞 2011-03-18
  • 打赏
  • 举报
回复
你是要宏还是要SQL?
intellectual1 2011-03-18
  • 打赏
  • 举报
回复
excel 宏谁会写?谢谢!
快溜 2011-03-18
  • 打赏
  • 举报
回复
没看明白 A2为啥是CC13
AcHerat 2011-03-18
  • 打赏
  • 举报
回复

/*
A B C D E F
1 Cc12 Cc13 Cc14 Cc15 Cc16
2 Cc13 背景色
3 Cc15 背景色 背景色 背景色
*/

declare @b int --字段的数据类型,用int为例!
declare @c int
declare @d int
declare @e int
declare @f int
declare @beijing int --背景色
select @b = b,@c = c,@d = d,@e = e,@f = f from tb where a = 1

update tb
set b = (case when b < @b then @beijing else b end),
c = (case when c < @c then @beijing else c end),
d = (case when d < @d then @beijing else d end),
e = (case when e < @e then @beijing else e end),
f = (case when f < @f then @beijing else f end)
where a > 1
intellectual1 2011-03-18
  • 打赏
  • 举报
回复
那里人太少了,这里应该有人会的。
王向飞 2011-03-18
  • 打赏
  • 举报
回复
去 开发语言→office开发/VBA 版块
Excel2007图表完全剖析 6/8 Excel2007 图表 完全剖析 OFFICE2007 完整清晰版 PDF ,有目录。共 150MB,分为8个分卷 原价:45.00元 作者:杰莱 出版社:人民邮电出版社 出版日期:2008年2月1日 ISBN:9787115171955 页码:354 -------------------------------------------------------------------------------- 内容提要  在Excel 2007中,Microsoft重写了15年来未曾更新的图表引擎,但如果选择的图表类型不正确,将无助于传递要表达的信息。鉴于此,本书将介绍Excel 2007中全新的图表制作界面,更重要的是,将引导读者选择正确的图表类型并创建引人入胜的图表。通过阅读本书,读者将迅速创建出让观众发出惊叹的图表,并有效地表达信息。   全书分为14章和一个附录,包括如下内容:学习使用Excel 2007图表制作界面,掌握使用图形有效地表示数据的方式,根据要传达的信息选择正确的图表类型,学习可节省时间的解决方案,创建大多数人认为使用Excel无法创建的图表,使用数据透视图汇总数百万行数据,在不使用图表的情况下以图形方式显示数据,使用SmartArt图形绘制流程图和关系图,使用VBA创建图表,将数据绘制到地图中,将图表导出到网页或PowerPoint中,找出图表背后的谎言等。   本书语言简明清晰,内容实用,实例丰富,适合需要使用Excel制作图表的人员阅读。 第1章 Excel 2007图表简介 1 1.1 Excel 2007中的新图表特性 1 1.2 新的图表工具和菜单 2 1.2.1 使用“插入”选项卡来插入图表 3 1.2.2 使用“展开”图标来访问所有图表类型图库 3 1.2.3 理解图表缩略图图标 4 1.2.4 使用图库控件 6 1.3 创建图表 7 1.3.1 选择连续的数据到图表中 7 1.3.2 选择非连续的数据到图表中 7 1.3.3 使用“插入选项卡”图标创建图表 8 1.3.4 使用一次击键创建图表 9 1.4 使用图表 9 1.4.1 在当前工作表中移动图表 9 1.4.2 反转图表的系列(series)与类别(category) 11 1.4.3 使用“选择数据”来改变数据顺序 12 1.4.4 将左上角单元格留空 13 1.4.5 将图表移到另一个工作表中 14 1.5 使用“设计”选项卡自定义图表 15 1.5.1 选择图表布局 16 1.5.2 选择颜色方案 16 1.5.3 通过改变主题来修改颜色方案 17 1.6 创建自己的主题 18 1.6.1 从已有的主题中选择自定义主题的效果 18 1.6.2 理解RGB颜色码 19 1.6.3 将十六进制转换为RGB 20 1.6.4 查找互补色 20 1.6.5 指定主题的颜色 21 1.6.6 指定主题的字体 22 1.6.7 保存自定义的主题 22 1.6.8 在新文档中使用自定义的主题 23 1.6.9 与他人共享主题 23 1.7 下一步 24 第2章 定制图表 25 2.1 使用设置元素格式的工具 25 2.2 识别图表元素 26 2.2.1 图表标签与坐标轴 26 2.2.2 三维图表中的特殊元素 27 2.2.3 分析元素 28 2.3 设置图表元素格式 29 2.3.1 设置图表标题格式 29 2.3.2 设置坐标轴标题格式 31 2.3.3 设置图例格式 32 2.3.4 在图表中添加数据标签 34 2.3.5 在图表中添加数据表 36 2.3.6 设置坐标轴格式 37 2.3.7 网格线的显示与格式设置 43 2.3.8 设置绘图区格式 45 2.3.9 设置三维图表中的背景墙与基底的格式 48 2.3.10 控制三维图表的三维旋转 49 2.3.11 使用趋势线进行预测 51 2.3.12 在折线图或面积图中添加垂直线 53 2.3.13 添加涨/跌柱线到图表中 54 2.3.14 使用误差线显示可接受的偏差 55 2.4 设置数据系列的格式 55 2.5 使用“格式”选项卡 56 2.5.1 将文本转换为艺术字 56 2.5.2 使用形状样式图库 57 2.5.3 使用形状填充与形状效果 57 2.5.4 使用预设形状效果 58 2.6 使用剪贴画或形状替换数据标记 59 2.6.1 使用剪贴画作为数据标记 59 2.6.2 使用形状替换数据标记 60 2.7 下一步 61 第3章 创建显示趋势的图表 62 3.1 选择图表类型 62 3.2 理解基于日期的坐标轴与基于类别的坐标轴 65 3.2.1 将文本日期转换为日期 66 3.2.2 不被识别为日期的日期:数字年份 71 3.2.3 不被识别为日期的日期:1900年之前的日期 72 3.2.4 使用其他方法显示使用时间刻度的坐标轴 76 3.2.5 将日期转换为文本以添加装饰性图表元素 78 3.3 使用图表进行有效交流 81 3.3.1 使用有意义的长标题解释图表的含义 82 3.3.2 突出一列 85 3.3.3 用箭头取代柱形 86 3.3.4 添加另一个序列来突出图表的一部分 87 3.3.5 中途改变折线类型 88 3.4 在图表中添加自动趋势线 89 3.5 显示月销量及当年累积销量的趋势 90 3.6 理解堆积柱形图的缺点 91 3.7 在单个图表中显示很多趋势线的缺点 93 3.8 使用散点图显示趋势 94 3.9 下一步 95 第4章 创建显示差异的图表 96 4.1 比较实体 96 4.2 使用条形图比较数据项 96 4.2.1 增加另一列来显示时间的比较 98 4.2.2 分割条形以突出组分 99 4.3 比较组分 100 4.3.1 使用饼图 101 4.3.2 切换到百分比堆积柱形图 106 4.3.3 使用圆环图来比较两个饼图 107 4.3.4 处理饼图中的数据表示问题 108 4.4 使用瀑布图(waterfall)分解组分 114 4.5 下一步 116 第5章 创建显示关系的图表 117 5.1 在图表中比较两个变量 117 5.2 使用XY散点图绘制成对的数据点 118 5.2.1 在散点图中添加趋势线 118 5.2.2 在散点图中添加标签 120 5.2.3 用折线连接散点图中的点 121 5.2.4 在散点图中添加第二个系列 122 5.2.5 用散点图画图 123 5.3 使用图表来显示关系 123 5.3.1 使用散点图来测试相关性 124 5.3.2 使用成对的条形图来显示关系 126 5.3.3 使用成对的匹配图表 132 5.3.4 使用气泡图添加第三维 135 5.3.5 使用频数分布将成千上万的点分类 136 5.3.6 使用雷达图评估绩效 138 5.3.7 来自Gene Zelazny的一个图表 142 5.4 使用曲面图 145 5.4.1 使用竖坐标轴 146 5.4.2 通过三维旋转控制曲面图 146 5.5 下一步 147 第6章 创建股票分析图 148 6.1 股价图概述 148 6.1.1 折线图 148 6.1.2 OHLC图 149 6.1.3 烛柱(candlestick)图 149 6.2 获取股价数据 150 6.2.1 重排下载数据中的列 151 6.2.2 使用“调整后的收盘价”列来处理分股 151 6.3 创建折线图来显示收盘价 153 6.4 创建OHLC图 156 6.4.1 创建盘高-盘低-收盘图 156 6.4.2 创建OHLC图 159 6.4.3 在盘高-盘低-收盘图表中添加成交量 161 6.5 创建烛柱图 165 6.5.1 改变烛柱图的颜色 166 6.5.2 在烛柱图中添加成交量 166 6.5.3 手工创建包含成交量的烛柱图 167 6.6 使用Web连接创建实时图表 171 6.7 创建用于Dashboard的小图表 174 6.8 下一步 175 第7章 高级图表技巧 176 7.1 高级图表技巧工具箱 176 7.1.1 在单个图表中使用两种图表类型 176 7.1.2 将图表从一个工作表移到另一个工作表 177 7.1.3 使用形状来注释图表 178 7.1.4 使柱形与条形悬浮 180 7.1.5 使用虚构的xy系列给纵坐标轴加上标签 182 7.1.6 使用虚构的XY系列将几个图表显示在单个图表中 187 7.1.7 使用多个XY系列创建网格图(trellis chart) 191 7.2 创建动态图表 195 7.2.1 使用OFFSET函数指定特定区域 195 7.2.2 使用VLOOKUP或MATCH在表格中查找值 196 7.2.3 结合使用INDEX和MATCH函数 198 7.2.4 使用“有效性”下拉列表创建动态图表 199 7.2.5 在图表中使用动态区域 201 7.2.6 创建滚动图表 204 7.2.7 修改滚动条示例显示最近12个月 206 7.3 创建高级图表 206 7.3.1 温度计图表 206 7.3.2 基准图 207 7.3.3 增量图(delta chart) 208 7.4 使用Excel创建奇妙的图表 209 7.5 下一步 211 第8章 创建和使用数据透视图 212 8.1 Excel 2007数据透视表的新特性 212 8.2 决定先使用哪一个:表格还是图表 213 8.3 准备底层透视数据的规则 213 8.4 创建第一个数据透视图 214 8.4.1 更改图表类型及设置图表格式 216 8.4.2 在数据透视图中添加系列 216 8.5 通过数据透视表执行高级操作 217 8.6 筛选数据透视表 219 8.6.1 使用“报表筛选”进行筛选 219 8.6.2 将Excel 2007筛选条件用于轴字段和图例字段 220 8.7 为每个顾客创建图表 221 8.8 下一步 223 第9章 不使用图表的数据可视化表示法 224 9.1 在工作表单元格中创建图表 224 9.2 使用数据条创建单元格内的条形图 225 9.2.1 定制数据条 225 9.2.2 控制最小/最大数据条的长度 226 9.2.3 在部分单元格中显示数据条 228 9.3 使用色阶来突出极值 230 9.3.1 转换为单色数据条 230 9.3.2 排除色阶问题 231 9.4 使用图标集区分数据 232 9.4.1 建立图标集 232 9.4.2 让数字靠近图标 233 9.5 使用条件格式在工作表单元格中创建图表 234 9.6 使用REPT函数创建图表 237 9.7 使用滚动条控件创建图表 238 9.8 创建“茎叶”图表 240 9.8.1 创建将X作为叶的“茎叶”图表 241 9.8.2 使用长公式创建以数字作为叶的“茎叶”图表 242 9.8.3 使用排序和公式创建以数字作为叶的“茎叶”图表 243 9.9 下一步 244 第10章 使用Microsoft MapPoint将Excel 数据显示在地图中 245 10.1 绘制地理数据 245 10.2 在Excel中创建地图 246 10.3 在地图上使用图表 249 10.4 使用其他地图样式来显示数据 251 10.5 下一步 253 第11章 使用SmartArt图形和形状 254 11.1 理解SmartArt图形和形状 254 11.2 使用SmartArt 255 11.2.1 大多数SmartArt都有的元素 256 11.2.2 SmartArt类别简介 256 11.2.3 插入SmartArt 257 11.2.4 对SmartArt元素进行微观控制 260 11.2.5 在文本窗格中控制SmartArt形状 262 11.2.6 添加图像到SmartArt中 264 11.2.7 使用组织图时需要特别考虑的因素 265 11.2.8 使用受限制的SmartArt 267 11.3 为信息选择正确的布局 268 11.4 探索使用SmartArt图形的商业图表 268 11.4.1 使用“平衡”图来显示正/反决策 269 11.4.2 使用“向上箭头”来显示增长 269 11.4.3 使用“基本循环”布局显示重复的过程 269 11.4.4 使用“分离射线”图示显示公司与外部实体的关系 270 11.4.5 使用“表格列表”图示显示公司的部门 270 11.4.6 调整维恩图来显示关系 271 11.4.7 理解“标记的层次结构”图 272 11.4.8 使用其他SmartArt布局 273 11.5 使用形状显示单元格内容 273 11.5.1 处理形状 274 11.5.2 使用“任意多边形”形状创建自定义形状 275 11.6 使用艺术字显示有趣的标题 275 11.7 下一步 278 第12章 导出图表以便在 Excel外部使用 279 12.1 在PowerPoint或Word中显示Excel图表 279 12.1.1 将图表复制为链接到原工作簿链接的动态图表 280 12.1.2 将图表复制为与原工作簿拷贝链接的动态图表 281 12.1.3 将图表复制为图形 282 12.1.4 将图表粘贴为链接对象 283 12.1.5 在PowerPoint中创建图表,从Excel中复制数据 284 12.2 在网上展示图表 285 12.3 将图表导出为图形 286 12.3.1 使用VBA将图表导出为图像 286 12.3.2 使用Snag-it或OneNote捕获图表 286 12.3.3 将XPS转换为PDF 287 12.4 下一步 287 第13章 使用VBA创建图表 288 13.1 VBA简介 288 13.1.1 在Excel中启用VBA 289 13.1.2 在Excel中“开发工具”选项卡 289 13.1.3 Visual Basic编辑器 289 13.1.4 Visual Basic工具 290 13.1.5 录制器 291 13.1.6 理解面向对象的代码 291 13.2 学习VBA编程技巧 291 13.2.1 编写代码来处理任意大小的数据区域 292 13.2.2 使用超级变量(super-variable):对象变量 293 13.2.3 在引用对象时使用With和End With 294 13.2.4 续行 294 13.2.5 在代码中添加注释 294 13.3 针对Excel 2007的新图表特性进行编程 295 13.4 在VBA代码中引用图表和图表对象 295 13.5 创建图表 296 13.5.1 指定图表的大小和位置 296 13.5.2 引用特定的图表 297 13.6 录制“布局”和“设计”选项卡中的命令 299 13.6.1 指定内置的图表类型 299 13.6.2 指定模板图表类型 301 13.6.3 更改图表的布局或样式 301 13.7 使用SetElement模拟“布局”选项卡中的设置 303 13.8 使用VBA修改图表标题 308 13.9 模拟“格式”选项卡中的设置 308 13.10 自动化“设置数据系列格式”对话框中的设置 322 13.10.1 控制柱形图和条形图的系列间距和类别间距 323 13.10.2 将系列移到次要坐标轴上 324 13.10.3 旋转和分离圆形图表 325 13.10.4 控制复合饼图和复合条饼图 327 13.10.5 控制雷达图和曲面图 332 13.11 使用“监视”窗口查看对象的设置 333 13.12 将图表导出为图形 335 13.13 创建数据透视图 337 13.14 下一步 341 第14章 找出图表背后的谎言 342 14.1 使用透视进行欺骗 342 14.2 使用缩小的图表进行欺骗 343 14.3 使用刻度进行欺骗 344 14.4 由于Excel不配合导致的欺骗 344 14.5 通过模糊数据进行欺骗 345 14.6 有意使用图表进行欺骗 346 14.7 下一步 348 附录A 图表资源 349 A.1 其他图表资源 349 A.2 Gene Zelazny:商业图表制作大师 349 A.3 PowerFramework.com 349 A.4 Edward Tufte的书籍 350 A.5 图表制作教程网站 351 A.6 交互式培训 351 A.7 现场培训 352 A.8 有关图表制作的博客 352 A.9 视觉设计书店 352 A.10 专业图表设计师 353 A.11 图表制作工具和产品 353
自动生成VBA窗体菜单 '*************************** '* 菜单类 * '*************************** Option Explicit Private WithEvents MenuBar_MenuItem As MSForms.Label '菜单项 Private WithEvents WorkForm As MSForms.UserForm '工作窗口 Private WithEvents MenuBar As MSForms.Image '菜单栏 Private BackMenu_BackGroud As MSForms.Image '菜单背景图片 Private BackMenu_Caption As MSForms.Label '菜单标题标签 Private Const DISTANCE As Integer = 5 '菜单与左边框距离 Private Const MENUTOP As Integer = 2 '菜单项顶点Y轴位置 Private Const MENUHEIGHT As Integer = 14 '菜单项高度 Private intIndex As Integer '索引变量 Private sAction As String '名称变量 Private Property Let Index(N As Byte) '指定索引属性 intIndex = N End Property Private Property Get Index() As Byte '获得陇望蜀索引属性 Index = intIndex End Property Private Property Let OnAction(sAct As String) '行为属性 sAction = sAct End Property Private Property Get OnAction() As String OnAction = sAction End Property Public Sub AddMenu(wform As MSForms.UserForm, sCaption As String, sAction As String, Optional Acc As String = vbNullString) Dim MenuLeft As Single, MenuWidth As Single '由两个标签和一个图形控件组成一个主菜单项 MenuCount = MenuCount + 1 '主菜单项总数加1 Index = MenuCount '设置索引 Set WorkForm = wform With WorkForm Set MenuBar = .FormMenuBar Set BackMenu_Caption = .Controls.Add("forms.label.1") '添加一个标签,显示菜单标题 With BackMenu_Caption .Accelerator = Acc .AutoSize = True .BackStyle = fmBackStyleTransparent .Caption = sCaption .Font = "宋体" .Font.Size = 9 .Name = "BackMenu_Caption" & MenuCount .TextAlign = fmTextAlignCenter .Top = MENUTOP + 3 .WordWrap = False .Visible = True End With If MenuCount = 1 Then MenuLeft = DISTANCE Else With .Controls("BackMenu_Caption" & MenuCount - 1) MenuLeft = .Left + .Width End With End If MenuWidth = BackMenu_Caption.Width + 10 Set BackMenu_BackGroud = .Controls.Add("forms.image.1") '添加一个image,作为背景图片 With BackMenu_BackGroud .Name = "BackMenu_BackGroud" & MenuCount .BorderStyle = fmBorderStyleNone .Move MenuLeft, MENUTOP, MenuWidth, MENUHEIGHT .BackStyle = fmBackStyleTransparent .PictureSizeMode = fmPictureSizeModeStretch BackMenu_Caption.AutoSize = False BackMenu_Caption.Left = .Left BackMenu_Caption.Width = .Width End With BackMenu_Caption.ZOrder '将标签置前 Set MenuBar_MenuItem = .Controls.Add("forms.label.1") '添加一个Label,用于触发事件 With MenuBar_MenuItem .Name = "MenuBar_MenuItem" & MenuCount .BorderStyle = fmBorderStyleNone .BackStyle = fmBackStyleTransparent With BackMenu_BackGroud MenuBar_MenuItem.Move .Left, .Top, .Width, .Height End With End With End With OnAction = sAction End Sub Private Sub MenuBar_MenuItem_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If Button = 1 Then bMenuSelected = True: Menu_Select End Sub Private Sub MenuBar_Click() UnSelectLastMenu bMenuSelected = False End Sub Private Sub MenuBar_MenuItem_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) UnSelectLastMenu Call Menu_Select End Sub Private Sub MenuBar_MouseMove1(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If Not bMenuSelected Then UnSelectLastMenu End Sub Private Sub WorkForm_Click() '窗体单击时 UnSelectLastMenu bMenuSelected = False End Sub Private Sub WorkForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If Not bMenuSelected Then UnSelectLastMenu '窗体 End Sub Private Sub Menu_Select() '选择菜单 On Error Resume Next Dim Pt_Menu_RightBottom As POINTAPI, Pt_Menu_LeftTop As POINTAPI With WorkForm UnSelectLastMenu Set LastSelect_Menu = BackMenu_BackGroud With BackMenu_BackGroud .BorderStyle = fmBorderStyleSingle .BorderColor = RGB(0, 0, 128) .BackStyle = fmBackStyleOpaque If bMenuSelected = False Then WorkForm.Controls("BackMenu_BackGroud" & Index).BackColor = &HFFC0C0 Else WorkForm.Controls("BackMenu_BackGroud" & Index).BackColor = &HE0E0E0 pt.X = MenuBar_MenuItem.Left * 1.33 pt.Y = (MenuBar_MenuItem.Top + MenuBar_MenuItem.Height) * 1.33 + 3 ClientToScreen hForm, pt If OnAction "" Then Application.Run OnAction End If End If End With End With End Sub Private Sub UnSelectLastMenu() '取消上次选择 If Not LastSelect_Menu Is Nothing Then With LastSelect_Menu .Picture = LoadPicture() .BackStyle = fmBackStyleTransparent .BorderStyle = fmBorderStyleNone End With End If End Sub '********本模块结束********** '*************************** '* 菜单执行模块 * '*************************** Public Type POINTAPI X As Long Y As Long End Type Public Declare Function FindWindow Lib "user32.dll" Alias"FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Declare Function ClientToScreen Lib"user32"(ByVal hwnd As Long, lpPoint As POINTAPI) As Long Public Popup_Menu As CommandBar '指定弹出式菜单 Public LastSelect_Menu As MSForms.Image '最后选择的菜单 Public MenuCount As Integer '子菜单数量 Public hForm As Long '窗口句柄 Public intLevel As Integer '级别标识,用于设置Radio菜单(游戏菜单中:初级,中级,高级) Public bAbortEnabled As Boolean '标识放弃菜单项是否可用 Public bItemCheck As Boolean '标识音效菜单是否CheckOn Public bMenuSelected As Boolean '标识菜单是否点击 Public pt As POINTAPI '定义点 Public faceid As Integer '图标ID Public faceidselect As Integer '选择的图标 Public fistid As Integer '第一个图标号 Public lastid As Integer '最后一个图标号 Public selectrow,selectcol as integer Public Mcro(50) AS String SUB 文件() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "打开 ", "", False, True,33,"" AddCustomCommandBarPopup1 "新建 ", "BB", False, True,18,"" AddCustomCommandBarPopup2 ("另存为 ") Set cmb = Application.CommandBars("CELL").Controls("另存为 ") AddCustomCommandBarPopup3 cmb, "OFFICE 97-2003文件 ", "DD", False, True, 3, "" Set cmb = Application.CommandBars("CELL").Controls("另存为 ") AddCustomCommandBarPopup4 cmb, "OFFICE 2007工作表 " Set cmb = Application.CommandBars("CELL").Controls("另存为 ").Controls("OFFICE 2007工作表 ") AddCustomCommandBarPopup3 cmb, "office 2007启用的工作表 ", "FF", False, True, 0, "" Set cmb = Application.CommandBars("CELL").Controls("另存为 ").Controls("OFFICE 2007工作表 ") AddCustomCommandBarPopup3 cmb, "OFFICE 2007工作表 ", "GG", False, True, 253, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 公式() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "文本 ", "WB", False, True,7,"" AddCustomCommandBarPopup2 ("名称 ") Set cmb = Application.CommandBars("CELL").Controls("名称 ") AddCustomCommandBarPopup3 cmb, "定义 ", "DY", False, True, 0, "" Set cmb = Application.CommandBars("CELL").Controls("名称 ") AddCustomCommandBarPopup4 cmb, "单元格 " Set cmb = Application.CommandBars("CELL").Controls("名称 ").Controls("单元格 ") AddCustomCommandBarPopup3 cmb, "合并 ", "HB", False, True, 592, "" Set cmb = Application.CommandBars("CELL").Controls("名称 ").Controls("单元格 ") AddCustomCommandBarPopup3 cmb, "从属 ", "CS", False, True, 564, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 开发工具() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "插入 ", "CR", False, True,548,"" AddCustomCommandBarPopup1 "模式 ", "MS", False, True,590,"" AddCustomCommandBarPopup2 (" ") Set cmb = Application.CommandBars("CELL").Controls(" ") AddCustomCommandBarPopup3 cmb, "录制 ", "LZH", False, True, 205, "" Set cmb = Application.CommandBars("CELL").Controls(" ") AddCustomCommandBarPopup3 cmb, "安全性 ", "AQX", False, True, 279, "" Set cmb = Application.CommandBars("CELL").Controls(" ") AddCustomCommandBarPopup3 cmb, "查看代码 ", "CKDM", False, True, 289, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 窗口() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "并列比较 ", "BLBJ", False, True,250,"" AddCustomCommandBarPopup1 "冻结 ", "DJ", False, True,288,"" AddCustomCommandBarPopup1 "隐藏 ", "YC", False, True,237,"" AddCustomCommandBarPopup1 "拆分 ", "CF", False, True,292,"" AddCustomCommandBarPopup1 "取消冻结 ", "QXDJ", False, True,232,"" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 工具() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "拼写检查 ", "PXJC", False, True,246,"" AddCustomCommandBarPopup2 ("保护 ") Set cmb = Application.CommandBars("CELL").Controls("保护 ") AddCustomCommandBarPopup3 cmb, "保护工作表 ", "BHGZB", False, True, 277, "" Set cmb = Application.CommandBars("CELL").Controls("保护 ") AddCustomCommandBarPopup3 cmb, "保护工作薄 ", "BHGZBB", False, True, 312, "" Set cmb = Application.CommandBars("CELL").Controls("保护 ") AddCustomCommandBarPopup3 cmb, "工作表菜单栏 ", "gzbcdl", False, True, 142, "" Set cmb = Application.CommandBars("CELL").Controls("保护 ") AddCustomCommandBarPopup3 cmb, "图表菜单栏 ", "tbgjl", False, True, 164, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 常用() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "格式 ", "gs", False, True,108,"" AddCustomCommandBarPopup1 "数据透视表 ", "sjtsb", False, True,125,"" AddCustomCommandBarPopup1 "图表 ", "tb", False, True,127,"" AddCustomCommandBarPopup1 "审阅 ", "sy", False, True,124,"" AddCustomCommandBarPopup1 "窗体 ", "ct", False, True,128,"" AddCustomCommandBarPopup1 "停止录制 ", "tzlz", False, True,185,"" AddCustomCommandBarPopup2 ("外部数据 ") Set cmb = Application.CommandBars("CELL").Controls("外部数据 ") AddCustomCommandBarPopup3 cmb, "公式审核 ", "gssh", False, True, 129, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ") AddCustomCommandBarPopup3 cmb, "全屏显示 ", "qpxs", False, True, 130, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ") AddCustomCommandBarPopup3 cmb, "循环引用 ", "xhye", False, True, 132, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ") AddCustomCommandBarPopup4 cmb, "VisualBasic " Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "Web ", "web", False, True, 173, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "控件工具箱 ", "kjgjx", False, True, 174, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "退出设计模式 ", "tcsjms", False, True, 162, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "刷新 ", "sx", False, True, 165, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "监视窗口 ", "jsck", False, True, 168, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "数据透视表字段列表 ", "sjtsbzdb", False, True, 170, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "边框 ", "bk", False, True, 178, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "保护 ", "bh", False, True, 160, "" Set cmb = Application.CommandBars("CELL").Controls("外部数据 ").Controls("VisualBasic ") AddCustomCommandBarPopup3 cmb, "文本到语音 ", "wbdyy", False, True, 164, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 列表() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "并排比较 ", "bpbj1", False, True,180,"" AddCustomCommandBarPopup1 "绘图 ", "bpbj2", False, True,182,"" AddCustomCommandBarPopup1 "数据透视图菜单 ", "bpbj3", False, True,184,"" AddCustomCommandBarPopup2 ("工作簿标签 ") AddCustomCommandBarPopup2 ("单元格 ") Set cmb = Application.CommandBars("CELL").Controls("单元格 ") AddCustomCommandBarPopup3 cmb, "列 ", "bpbj6", False, True, 190, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ") AddCustomCommandBarPopup3 cmb, "行 ", "bpbj7", False, True, 192, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ") AddCustomCommandBarPopup3 cmb, "单元格 ", "bpbj8", False, True, 194, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ") AddCustomCommandBarPopup3 cmb, "柱形图 ", "bpbj9", False, True, 196, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ") AddCustomCommandBarPopup3 cmb, "行 ", "bpbj10", False, True, 198, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ") AddCustomCommandBarPopup4 cmb, "工作表 " Set cmb = Application.CommandBars("CELL").Controls("单元格 ").Controls("工作表 ") AddCustomCommandBarPopup3 cmb, "XLM 单元格 ", "bpbj12", False, True, 202, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ").Controls("工作表 ") AddCustomCommandBarPopup3 cmb, "文档 ", "bpbj13", False, True, 204, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ").Controls("工作表 ") AddCustomCommandBarPopup3 cmb, "桌面 ", "bpbj14", False, True, 206, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ").Controls("工作表 ") AddCustomCommandBarPopup3 cmb, "非默认拖放 ", "bpbj15", False, True, 208, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ").Controls("工作表 ") AddCustomCommandBarPopup3 cmb, "自动填充 ", "bpbj16", False, True, 210, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ").Controls("工作表 ") AddCustomCommandBarPopup3 cmb, "按钮 ", "bpbj17", False, True, 212, "" Set cmb = Application.CommandBars("CELL").Controls("单元格 ").Controls("工作表 ") AddCustomCommandBarPopup3 cmb, "对话框 ", "bpbj18", False, True, 214, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 序列() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "图形区 ", "bpbj20", False, True,218,"" AddCustomCommandBarPopup1 "基底和墙纸 ", "bpbj21", False, True,220,"" AddCustomCommandBarPopup1 "趋势线 ", "bpbj22", False, True,222,"" AddCustomCommandBarPopup1 "图表 ", "bpbj23", False, True,224,"" AddCustomCommandBarPopup1 "设置数据系列格式 ", "bpbj24", False, True,226,"" AddCustomCommandBarPopup2 ("设置数据轴格式 ") Set cmb = Application.CommandBars("CELL").Controls("设置数据轴格式 ") AddCustomCommandBarPopup3 cmb, "设置图例项格式 ", "bpbj26", False, True, 230, "" Set cmb = Application.CommandBars("CELL").Controls("设置数据轴格式 ") AddCustomCommandBarPopup3 cmb, "编辑栏 ", "bpbj27", False, True, 232, "" Set cmb = Application.CommandBars("CELL").Controls("设置数据轴格式 ") AddCustomCommandBarPopup3 cmb, "数据透视表上下文菜单 ", "bpbj28", False, True, 234, "" Set cmb = Application.CommandBars("CELL").Controls("设置数据轴格式 ") AddCustomCommandBarPopup3 cmb, "查询 ", "bpbj29", False, True, 236, "" Set cmb = Application.CommandBars("CELL").Controls("设置数据轴格式 ") AddCustomCommandBarPopup3 cmb, "查询布局 ", "bpbj30", False, True, 238, "" Set cmb = Application.CommandBars("CELL").Controls("设置数据轴格式 ") AddCustomCommandBarPopup4 cmb, "自动计算 " Set cmb = Application.CommandBars("CELL").Controls("设置数据轴格式 ").Controls("自动计算 ") AddCustomCommandBarPopup3 cmb, "对象/图形区 ", "bpbj32", False, True, 242, "" Set cmb = Application.CommandBars("CELL").Controls("设置数据轴格式 ").Controls("自动计算 ") AddCustomCommandBarPopup3 cmb, "标题栏(图表) ", "bpbj33", False, True, 244, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 框架() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "数据透视图快捷菜单 ", "bpbj35", False, True,248,"" AddCustomCommandBarPopup1 "拼音信息 ", "bpbj36", False, True,250,"" AddCustomCommandBarPopup1 "自动合计 ", "bpbj37", False, True,252,"" AddCustomCommandBarPopup1 "选择性粘贴下拉框 ", "bpbj38", False, True,254,"" AddCustomCommandBarPopup2 ("查找格式 ") Set cmb = Application.CommandBars("CELL").Controls("查找格式 ") AddCustomCommandBarPopup3 cmb, "替换格式 ", "bpbj40", False, True, 258, "" Set cmb = Application.CommandBars("CELL").Controls("查找格式 ") AddCustomCommandBarPopup3 cmb, "列表区域快捷菜单 ", "bpbj41", False, True, 260, "" Set cmb = Application.CommandBars("CELL").Controls("查找格式 ") AddCustomCommandBarPopup3 cmb, "列表区域布局快捷菜单 ", "bpbj42", False, True, 262, "" Set cmb = Application.CommandBars("CELL").Controls("查找格式 ") AddCustomCommandBarPopup3 cmb, "XML 区域快捷菜单 ", "bpbj43", False, True, 264, "" Set cmb = Application.CommandBars("CELL").Controls("查找格式 ") AddCustomCommandBarPopup3 cmb, "列表区域布局快捷菜单 ", "bpbj44", False, True, 266, "" Set cmb = Application.CommandBars("CELL").Controls("查找格式 ") AddCustomCommandBarPopup3 cmb, "艺术字 ", "bpbj45", False, True, 268, "" AddCustomCommandBarPopup2 ("图片 ") Set cmb = Application.CommandBars("CELL").Controls("图片 ") AddCustomCommandBarPopup3 cmb, "阴影设置 ", "bpbj47", False, True, 272, "" AddCustomCommandBarPopup2 ("三维设置 ") Set cmb = Application.CommandBars("CELL").Controls("三维设置 ") AddCustomCommandBarPopup3 cmb, "绘图画布 ", "bpbj49", False, True, 276, "" Set cmb = Application.CommandBars("CELL").Controls("三维设置 ") AddCustomCommandBarPopup3 cmb, "组织结构图 ", "bpbj50", False, True, 278, "" Set cmb = Application.CommandBars("CELL").Controls("三维设置 ") AddCustomCommandBarPopup3 cmb, "图示 ", "bpbj51", False, True, 280, "" Set cmb = Application.CommandBars("CELL").Controls("三维设置 ") AddCustomCommandBarPopup3 cmb, "墨迹绘图与书写 ", "bpbj52", False, True, 282, "" Set cmb = Application.CommandBars("CELL").Controls("三维设置 ") AddCustomCommandBarPopup3 cmb, "墨迹注释 ", "bpbj53", False, True, 284, "" AddCustomCommandBarPopup2 ("边框 ") Set cmb = Application.CommandBars("CELL").Controls("边框 ") AddCustomCommandBarPopup3 cmb, "边框 ", "bpbj55", False, True, 288, "" Set cmb = Application.CommandBars("CELL").Controls("边框 ") AddCustomCommandBarPopup4 cmb, "绘图边框 " Set cmb = Application.CommandBars("CELL").Controls("边框 ").Controls("绘图边框 ") AddCustomCommandBarPopup3 cmb, "图表类型 ", "bpbj57", False, True, 292, "" Set cmb = Application.CommandBars("CELL").Controls("边框 ").Controls("绘图边框 ") AddCustomCommandBarPopup3 cmb, "图案 ", "bpbj58", False, True, 294, "" Set cmb = Application.CommandBars("CELL").Controls("边框 ").Controls("绘图边框 ") AddCustomCommandBarPopup3 cmb, "字体颜色 ", "bpbj59", False, True, 296, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 填充颜色() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "线条颜色 ", "bpbj61", False, True,300,"" AddCustomCommandBarPopup2 ("绘图与书写笔 ") Set cmb = Application.CommandBars("CELL").Controls("绘图与书写笔 ") AddCustomCommandBarPopup3 cmb, "批注笔 ", "bpbj63", False, True, 304, "" Set cmb = Application.CommandBars("CELL").Controls("绘图与书写笔 ") AddCustomCommandBarPopup3 cmb, "绘图和书写笔 ", "bpbj64", False, True, 306, "" Set cmb = Application.CommandBars("CELL").Controls("绘图与书写笔 ") AddCustomCommandBarPopup3 cmb, "注释笔 ", "bpbj65", False, True, 308, "" Set cmb = Application.CommandBars("CELL").Controls("绘图与书写笔 ") AddCustomCommandBarPopup3 cmb, "叠放次序 ", "bpbj66", False, True, 310, "" Set cmb = Application.CommandBars("CELL").Controls("绘图与书写笔 ") AddCustomCommandBarPopup3 cmb, "微移 ", "bpbj67", False, True, 312, "" Set cmb = Application.CommandBars("CELL").Controls("绘图与书写笔 ") AddCustomCommandBarPopup3 cmb, "对齐或分布 ", "bpbj68", False, True, 314, "" AddCustomCommandBarPopup2 ("旋转或翻转 ") Set cmb = Application.CommandBars("CELL").Controls("旋转或翻转 ") AddCustomCommandBarPopup3 cmb, "直线 ", "bpbj70", False, True, 318, "" Set cmb = Application.CommandBars("CELL").Controls("旋转或翻转 ") AddCustomCommandBarPopup4 cmb, "连接符 " Set cmb = Application.CommandBars("CELL").Controls("旋转或翻转 ").Controls("连接符 ") AddCustomCommandBarPopup3 cmb, "自选图形 ", "bpbj72", False, True, 322, "" Set cmb = Application.CommandBars("CELL").Controls("旋转或翻转 ").Controls("连接符 ") AddCustomCommandBarPopup3 cmb, "标注 ", "bpbj73", False, True, 324, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 流程图() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "箭头总汇 ", "bpbj75", False, True,328,"" AddCustomCommandBarPopup1 "星与旗帜 ", "bpbj76", False, True,330,"" AddCustomCommandBarPopup1 "基本形状 ", "bpbj77", False, True,332,"" AddCustomCommandBarPopup1 "插入形状 ", "bpbj78", False, True,334,"" AddCustomCommandBarPopup2 ("形状 ") Set cmb = Application.CommandBars("CELL").Controls("形状 ") AddCustomCommandBarPopup3 cmb, "非活动图表 ", "bpbj80", False, True, 338, "" Set cmb = Application.CommandBars("CELL").Controls("形状 ") AddCustomCommandBarPopup3 cmb, "Excel 控件 ", "bpbj81", False, True, 340, "" AddCustomCommandBarPopup1 "曲线 ", "bpbj82", False, True,342,"" AddCustomCommandBarPopup1 "曲线结点 ", "bpbj83", False, True,344,"" AddCustomCommandBarPopup1 "曲线段 ", "bpbj84", False, True,346,"" AddCustomCommandBarPopup1 "图片上下文菜单 ", "bpbj85", False, True,348,"" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB OLE对象() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "ActiveX 控件 ", "bpbj87", False, True,352,"" AddCustomCommandBarPopup1 "艺术字上下文菜单 ", "bpbj88", False, True,354,"" AddCustomCommandBarPopup1 "旋转方式 ", "bpbj89", False, True,356,"" AddCustomCommandBarPopup1 "连接符 ", "bpbj90", False, True,358,"" AddCustomCommandBarPopup1 "脚本标记快捷菜单 ", "bpbj91", False, True,360,"" AddCustomCommandBarPopup1 "Canvas Popup ", "bpbj92", False, True,362,"" AddCustomCommandBarPopup1 "Organization Chart Popup ", "bpbj93", False, True,364,"" AddCustomCommandBarPopup2 ("图表 ") Set cmb = Application.CommandBars("CELL").Controls("图表 ") AddCustomCommandBarPopup3 cmb, "选择 ", "bpbj95", False, True, 368, "" Set cmb = Application.CommandBars("CELL").Controls("图表 ") AddCustomCommandBarPopup4 cmb, "版式 " Set cmb = Application.CommandBars("CELL").Controls("图表 ").Controls("版式 ") AddCustomCommandBarPopup3 cmb, "符号栏 ", "bpbj97", False, True, 372, "" Set cmb = Application.CommandBars("CELL").Controls("图表 ").Controls("版式 ") AddCustomCommandBarPopup3 cmb, "任务窗格 ", "bpbj98", False, True, 374, "" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 添加命令() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "内置菜单 ", "bpbj100", False, True,378,"" AddCustomCommandBarPopup1 "剪贴板 ", "bpbj101", False, True,380,"" AddCustomCommandBarPopup1 "信封 ", "bpbj102", False, True,382,"" AddCustomCommandBarPopup1 "联机会议 ", "bpbj103", False, True,384,"" AddCustomCommandBarPopup1 "SnagIt ", "bpbj104", False, True,386,"" Popup_Menu.ShowPopup pt.X, pt.Y END SUB SUB 关于() Clear_menu '清除弹出菜单上菜单项 Dim cmb As CommandBarControl AddCustomCommandBarPopup1 "我的VBA ", "WDVBA", False, True,400,"" AddCustomCommandBarPopup1 "帮助 ", "BZ", False, True,402,"" Popup_Menu.ShowPopup pt.X, pt.Y END SUB Public Sub ClearBar() '清除Cell弹出式菜单中菜单项 Dim ctr As CommandBarControl With Popup_Menu .Enabled = True For Each ctr In .Controls ctr.Delete Next End With End Sub Sub RemoveCustomMenu() '恢复系统菜单的各弹出菜单 Application.CommandBars("CELL").Reset End Sub Sub clear_menu() Dim cmb As Object For Each cmb In Application.CommandBars("cell").Controls Application.CommandBars("cell").Controls(cmb.Caption).Delete Next End Sub Sub AddCustomCommandBarPopup1(Caption As String, Macro As String, NewGroup As Boolean, Enable As Boolean, FId As Integer, ShortT As String) '添加一级菜单选项 Dim cbb As CommandBarButton Set cbb = Application.CommandBars("CELL").Controls.Add(msoControlButton) cbb.Caption = Caption If FId > 0 Then cbb.faceid = FId If ShortT "" Then cbb.ShortcutText = ShortT cbb.OnAction = Macro cbb.BeginGroup = NewGroup cbb.Enabled = Enable End Sub Function AddCustomCommandBarPopup2(Caption As String) As CommandBarControl '添加子菜单项 Dim cmb As CommandBarControl Set cmb = Application.CommandBars("CELL").Controls.Add(msoControlPopup) cmb.Caption = Caption cmb.Visible = True Set AddCustomCommandBarPopup2 = cmb End Function Sub AddCustomCommandBarPopup3(cmb As Object, Caption As String, Macro As String, NewGroup As Boolean, Enable As Boolean, FId As Integer, ShortT As String) '添加一级菜单选项 Dim cbc As CommandBarButton Set cbc = cmb.Controls.Add(msoControlButton) cbc.Caption = Caption If FId > 0 Then cbc.faceid = FId If ShortT "" Then cbc.ShortcutText = ShortT cbc.OnAction = Macro cbc.BeginGroup = NewGroup cbc.Enabled = Enable End Sub Function AddCustomCommandBarPopup4(cmd As CommandBarControl, Caption As String) As CommandBarControl '添加子菜单项 Dim cme As CommandBarControl Set cme = cmd.Controls.Add(msoControlPopup) cme.Caption = Caption cme.Visible = True Set AddCustomCommandBarPopup4 = cme End Function '********本模块结束********** '*************************** '* 窗口模块 * '*************************** Private menu(1 To 50) As New Menu_Class '定义50个cMenu菜单类型 Private Sub UserForm_Initialize() hForm = FindWindow(vbNullString, Me.Caption) '程序中需要用到窗口句柄,先获得它 MenuCount = 0 Set Popup_Menu = Application.CommandBars("Cell") '程序中需指定一个弹出式菜单,我们指定为单元格右键菜单,您可另外指定一个弹出式菜单,请注意,是弹出式菜单 Dim bar As Control Set bar = Me.Controls.Add("Forms.image.1", "IM1", Visible) With bar .Visible = True .Left = -100 .Top = 0 .Height = 20 .Width = 20 .BackColor = &HFFC0C0 .BorderStyle = 0 End With '*************** Set bar = Me.Controls.Add("Forms.image.1", "IM2", Visible) With bar .Visible = True .Left = -100 .Top = 0 .Height = 20 .Width = 20 .BackColor = &HFFC0C0 .BorderStyle = 0 End With '*************** Set bar = Me.Controls.Add("Forms.image.1", "FormMenuBar", Visible) With bar .Visible = True .Left = -1 .Top = -1 .Height = 20 .Width = 2000 .BackColor = &HFFC0C0 .BorderStyle = 0 End With menu(1).AddMenu Me,"文件","文件","" menu(2).AddMenu Me,"公式","公式","" menu(3).AddMenu Me,"开发工具","开发工具","" menu(4).AddMenu Me,"窗口","窗口","" menu(5).AddMenu Me,"工具","工具","" menu(6).AddMenu Me,"常用","常用","" menu(7).AddMenu Me,"列表","列表","" menu(8).AddMenu Me,"序列","序列","" menu(9).AddMenu Me,"框架","框架","" menu(10).AddMenu Me,"填充颜色","填充颜色","" menu(11).AddMenu Me,"流程图","流程图","" menu(12).AddMenu Me,"OLE对象","OLE对象","" menu(13).AddMenu Me,"添加命令","添加命令","" menu(14).AddMenu Me,"关于","关于","" end sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Dim i As Integer For i = LBound(menu) To UBound(menu) Set menu(i) = Nothing Next Popup_Menu.Enabled = True Popup_Menu.Reset end sub '********本模块结束**********
菜单功能一览表 【公农双历查询】【高级定位】【选区背景着色】【修改文件建立时间】【工作表环境设置】【按颜色合计】【根据工资计算钞票】【隔行插入行】【折分工作簿(工作表)】【工作表折分】【合并工作簿】【文本与数值互换】【复选框工具】【报表分栏工具箱】【删除工资条恢复明细表】【制作工资条】【建立分页小计】【删除分页小计】【建立图片目录】【批量导入图片(精确匹配)】【批量导入图片(模糊匹配)】【批量导入图片到批注】【删除所有图片】【批量导出图片】【图片查询工具】【将选区保存为图片】【生成个性化批注】 【插入GIF动画】【插入Flash动画】【禁止录入重复值】【相同项与不同项】【建文件目录】【提取选区重复值】【清除列中重复值】【标示重复值】【删除空白单元格所在行】【筛选唯一值】【建工作表目录】【批量新建复制工作表】【批量加解密】【工作表批量命名】【破解工作表/簿密码】 【批量命名文件】【可还原的合并】【合并列中相同值】【取消合并还原数据】【合并区域自动换行】【合并到选区】【合并数据并复制】【反向选择】【文本、数字分离与计算】【保护公式】【生成千年日历】【百家姓与字母序列】【一键隐藏非使用区】生成斜线表头】【打印当前页】【双面打印】【生成底端标题】【简体转繁体】【繁体转简体】【生成系统图标】【获取内置命令】【修复Excel】【破解VBA密码】【删除空单元格】【转置选区】【按列倒置】【按列倒置】【字母大小写转换】【小写金额转大写】【大写金额转小写】【区域数据加密】【多区域复制】【按颜色筛选】【按颜色排序】【返回首页】 自定义函数一览表 【sumifcol】【AVER】【hesum】【NOWW】【SFZ】【批注】【合并】【取数】【唯一值】【消除空值】【颜色求和】【颜色计数】【工作表】【数字】【分割取数】【共有项】不同项】【【公式】【计算】【公式长度】【大写】【排名】【排序】【替换】【重复】【文件目录】【File】 【公农双历查询】:生成多功能日历,可以查询所有节、假日和农历 【高级定位】:多功能选择(查找)工具。可以选择大于某值或者小于某值或者在某范围之间的值,文本定位时支持通配符。还可以按格式查找/定位 【背景着色】:将当前或者列进行颜色标示,以突出显示,有利于数据查看。可以随心所欲地定义颜色,还可以自由调整颜色的深浅。本工具相对于同类工具有不破坏背景色、条件格式、复制粘贴和撤消功能之优点 【环境设置】:设置工作表界面视图,控制各项目的显示与隐藏 【修改文件时间】:随心所欲修改文件的创建时间 【按颜色汇总】:按背景色对选区的数据合类合计 【反向选择】:选择当前区域中未选择的区域 【千年日历】:工单元格中生成千年日期。默认显示本月的日历,可以自由调整年月 【保护公式】:保护当前工作表所有公式,不让人看到公式本身,只能看到公式结果 【生成斜线表头】:Excel没有Word那样的斜线表头工具,本工具可以弥补此不足。包括单线、双线可选 【百家姓与字母序列】:运行后可以在单元格中进行百家姓与字母填充,提升录入速度 【一键隐藏非使用区】:对空白区域瞬间隐藏起来。可以选择作用对象是当前表还是所有工作表。恢复时也只要瞬间完成 【字符分离及计算】:批量地对单元格进行文本、数字分离,还可以计算取出的表达式 【删除空单元格】:删除选区的空单元格,后面的数据自动上升 【转置选区】:将选区行列调换 【按列倒置】:将选区的数据横向倒置 【按列倒置】:将选区的数据纵向倒置 【字母大小写转换】:将选区的单词、字母在大写小写、首字母大写之间转换 【小写金额转大写】:将小写金额批量转换成大写 【大写金额转小写】:将大写金额批量转换成小写 【区域数据加密】:对工作表选区的数据进行加密,转换成乱码,有密码才可以查看。 【简体转繁体】:将简体字批量转换成繁体 【繁体转简体】:将繁体字批量转换成简体 【根据工资计算钞票】:根据员工的工资计算需要多少张100元、50元......1元的钞票,可以批量计算。发现金工资的财务工作者必备 【隔行插入行】:对工作表隔行插入行,或者隔列插入列,其中行数可以自定义 【折分工作簿】:将指定工作簿的每个工作表拆分成单独的工作簿,新工作簿名称等于原工作表名称 【工作表折分】:将当前工作表的数据按条件拆分成多个工作表,可以用任意列的数据做为拆分条件 【合并工作簿】:将指文件夹中所有工作簿中所有工作表数据合并起来。有两种合并方式:将每个工作簿中的工作表合到当前工作簿是,表与表对应;将不同工作簿中同工作表的数据合并到同一工作表中。差异在于同名工作表的处理 【文本与数值互换】:将选区的数字瞬间转换成文本;将选区的文本型数字瞬间转换成数值 【

2,462

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧