可以式式宏,就是vbscript写的脚本,vstudio有一整套对象模型支持宏的
我记不清了,大概是
activedocument.selection.xxxxxxxx是插入字符的方法,疾步请了,翻番msdn把
我记不清了,大概是
activedocument.selection.xxxxxxxx是插入字符的方法,疾步请了,翻番msdn把
解决方案 »
- SetTimer 如何使用自定义回调函数,我定义的老是出错,麻烦高手帮忙
- 请教:关于字符串格式化成数据的问题??
- 窗体上的 SYSMENU如何只保留关闭按钮
- 用VC++如何做个像记事本的软件?
- 请问怎么初始化一个基于对话框的列表控件
- 100分求助:请问怎样在VC6.0中输出一个带文字的表格到word xp 中,如果能输出图片就更好了???
- 调试问题。
- 文件和文件流问题???
- 请教高手!利用vc++如何操纵用word生成的文档模板?急!!!
- GFlags 使用问题
- 请问如何打开一个指定路径的文件啊?
- 处理winamp的插件不就是写好其dll的接口函数吗?如何取得它的原型?我用vc只得到了它的函数名。
曾经找到一个addin,有时也会出错,胆子大一点,还可以用
Sub Comment()
s=Replace(ActiveDocument.Selection,vbCrLf,vbCrLf+"//")
s="//"+s
If Len(s)>2 and Mid(s,Len(s)-1,2) = "//" Then
s=Mid(s,1,Len(s)-2)
End If
ActiveDocument.Selection=s
End Sub
然后给这个宏定义一个快捷健不就行了
#if 0//你要注释的代码#endif //0
http://codeguru.earthweb.com/devstudio_macros/comment_uncomment.shtml
Sub CommentOut ()
'DESCRIPTION: Comments out a selected block of text.
Dim win
set win = ActiveWindow
if win.type <> "Text" Then
MsgBox "This macro can only be run when a text editor window is active."
else
CommentType = "//" StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If If EndLine = StartLine Then
ActiveDocument.Selection = CommentType + ActiveDocument.Selection
Else
For i = StartLine To EndLine
ActiveDocument.Selection.GoToLine i
ActiveDocument.Selection.SelectLine
ActiveDocument.Selection = CommentType + _
ActiveDocument.Selection
Next
End If
End If
End Sub
Sub UnCommentOut ()
'DESCRIPTION: Uncomments a selected block of text.
Dim win
set win = ActiveWindow
if win.type <> "Text" Then
MsgBox "This macro can only be run when a text editor window is active."
else
StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If For i = StartLine To EndLine
TmpBlock = "" ActiveDocument.Selection.GoToLine i
ActiveDocument.Selection.SelectLine
CmtBlock = ActiveDocument.Selection Trim(CmtBlock) If Instr(CmtBlock,"//") <> 0 Then
TmpBlock = TmpBlock + Left (CmtBlock, Instr (CmtBlock,"//") - 1)
CmtBlock = Right(CmtBlock, (Len(CmtBlock) - (Instr(CmtBlock, "//") + 1)))
CmtBlock = TmpBlock + CmtBlock
End If ActiveDocument.Selection = CmtBlock
Next End If
End Sub