'------------------------------------------------------------------------------
' VC - Tools - Macro...
'
' 在 "Macro Name:" 输入框中输入 abc,点击右边按钮"Edit"
'
' 在编辑视图中,Crtl+A,然后 Delete,删除全部
'
' 复制本Txt所有内容到刚才的编辑视图中,保存
'
' 再一次 VC - Tools - Macro...
'
' 点击按钮"Options>>",在扩展的界面上点击"KeyStrockes"按钮
'
' 在新的界面的"Commands:"列表框中选择"AddFunDescription"
'
' 鼠标点击"Press new shortcut",然后按 Ctrl + =
'
' 在输入框中会看到 "Ctrl + =",按右边的"Assign"按钮
'
' 依次类推,选中"Comment",按 Ctrl + /,点"Assign"按钮
'
' 依次类推,选中"ReComment",按 Ctrl + \,点"Assign"按钮
'
' 点"Close"按钮,完成
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
' 编写函数时,选择函数名,可以多行,按 Ctrl+= 就自动创建函数说明,但需要完整的填充说明
'
' 如果需要注释一部分代码,只需要选择这些行,按 Ctrl+/ 就自动 用//注释掉代码
'
' 对上面注释的取消,同样是选择这些行,按 Ctrl+\,即还原注释前的样子
'
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'FILE DESCRIPTION: New Macro File
'------------------------------------------------------------------------------
Sub Comment()
'DESCRIPTION: 注释选中的代码行
dim top, bottom, line
dim startCol, col
startCol = 1000
With ActiveDocument.Selection
top = .TopLine
bottom = .BottomLine
for line = top to bottom
.GoToLine line, dsSelect
.SelectLine
.ReplaceText "/*", "/&;*"
.ReplaceText "*/", "*&;/"
.StartOfLine dsFirstText
col = .CurrentColumn
if startCol > col then
startCol = col
end if
next
for line = top to bottom
.MoveTo line, startCol
'MsgBox .text
.Text = "// "
next
end with
End Sub
Sub ReComment()
'DESCRIPTION: 取消选中代码行的注释
dim top, bottom, line
dim startCol, col
With ActiveDocument.Selection
top = .TopLine
bottom = .BottomLine
for line = top to bottom
.GoToLine line, dsSelect
.SelectLine
.ReplaceText "/&;*", "/*"
.ReplaceText "*&;/", "*/"
.StartOfLine dsFirstText
.SelectLine
pos = InStr(.text, "//")
if pos > 0 then
.Cancel
.StartOfLine dsFirstText
.Delete 2
.CharRight dsExtend
if .Text = " " then
.Delete
end if
end if
next
End With
end Sub
Sub AddFunDescription()
'DESCRIPTION: 为选中的函数增加注释块
dim text, funHeader, funParms, docTab, Author
dim strFunName, strFunType
dim tmp(), strParms()
dim FunName, RetrunType, Parameters, History
docTab = 4 '制表符大小,本
程序中用来对齐参数列表
Author = "test" '请改成您
的大名
dim desc(18)
desc(0) = "/******************************************************************************"
desc(1) = "**" '空行
desc(2) = "**函数名称:" + vbTab '此处将添加函数名
desc(3) = "**"
desc(4) = "**功能描述:" + vbTab
desc(5) = "**"
desc(6) = "**参数说明:"
desc(7) = vbTab + vbTab '此处将添加参数
列表 desc(8) = "**"
desc(9) = "**返回类型: " '此处将添加函数类型
desc(10) = "**" + vbTab + vbTab + "[添加返回值说明]"
desc(11) = "**" + vbTab + vbTab
desc(12) = "**" + vbTab + vbTab
desc(13) = "**其他说明:" + vbTab
desc(14) = "**"
desc(15) = "**历史:" + vbTab + vbTab + "日期" + vbTab + vbTab + "作者" + vbTab + vbTab + "行为"
desc(16) = vbTab + vbTab
desc(17) = "******************