這些巨集腳本基本出自網上,本人只是略加修改,出處已無從考證,見諒!
- Imports System
- Imports EnvDTE
- Imports EnvDTE80
- Imports System.Diagnostics
- Public Module GenerateComment
- '插入文件头的说明(简体中文)
- Sub ClassHeaderCN()
- Dim doc As Document = DTE.ActiveDocument
- Dim docText As TextDocument = doc.Object
- Dim curText As TextSelection = docText.Selection
- 'Go to the header of the text
- curText.GotoLine(1)
- Dim strText As String
- strText = "/" + vbCrLf
- strText += "// 文 件 名:" + vbTab + doc.Name + vbCrLf
- strText += "// 功能描述:" + vbTab + vbCrLf
- strText += "// 编 写 人:" + vbTab + vbCrLf
- strText += "// 编写日期:" + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbCrLf
- strText += "// 修 改:" + vbTab + vbCrLf
- strText += "// 修 改 人:" + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbTab + "<建立>" + vbCrLf
- strText += "// 备 注:" + vbTab + vbCrLf
- strText += "/" + vbCrLf
- curText.Insert(strText)
- End Sub
- '插入文件头的说明(English)
- Sub ClassHeaderEN()
- Dim doc As Document = DTE.ActiveDocument
- Dim docText As TextDocument = doc.Object
- Dim curText As TextSelection = docText.Selection
- 'Go to the header of the text
- curText.GotoLine(1)
- Dim strText As String
- strText = "/" + vbCrLf
- strText += "//FileName:" + vbTab + doc.Name + vbCrLf
- strText += "//Function: " + vbTab + vbCrLf
- strText += "//Author: " + vbTab + vbCrLf
- strText += "//Date: " + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbCrLf
- strText += "//Modify: " + vbTab + vbCrLf
- strText += "//Editor: " + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbTab + "<Create>" + vbCrLf
- strText += "//Memo: " + vbTab + vbCrLf
- strText += "/" + vbCrLf
- curText.Insert(strText)
- End Sub
- '编辑文件时修改文件头(简体中文)
- Sub AddModificationCN()
- Dim doc As Document = DTE.ActiveDocument
- Dim docText As TextDocument = doc.Object
- Dim curText As TextSelection = docText.Selection
- curText.GotoLine(7)
- Dim strText As String
- strText = "// 修 改 人:" + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbTab + "<编辑>" + vbCrLf
- curText.Insert(strText)
- End Sub
- '编辑文件时修改文件头(English)
- Sub AddModificationEN()
- Dim doc As Document = DTE.ActiveDocument
- Dim docText As TextDocument = doc.Object
- Dim curText As TextSelection = docText.Selection
- curText.GotoLine(7)
- Dim strText As String
- strText = "//Editor: " + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbTab + "<Edit>" + vbCrLf
- curText.Insert(strText)
- End Sub
- '在函数前添加注释(简体中文)
- Sub FunctionCommentCN()
- Dim doc As Document = DTE.ActiveDocument
- Dim docText As TextDocument = doc.Object
- Dim curText As TextSelection = docText.Selection()
- Dim strText As String
- strText = "/" + vbCrLf
- strText += "//功能:" + vbCrLf
- strText += "//作者:" + vbCrLf
- strText += "//日期:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbCrLf
- strText += "//参数:" + vbCrLf
- strText += "//返回:" + vbCrLf
- strText += "/"
- curText.Insert(strText)
- End Sub
- '在函数前添加注释(English)
- Sub FunctionCommentEN()
- Dim doc As Document = DTE.ActiveDocument
- Dim docText As TextDocument = doc.Object
- Dim curText As TextSelection = docText.Selection()
- Dim strText As String
- strText = "/" + vbCrLf
- strText += "//Function: " + vbTab + vbCrLf
- strText += "//Author: " + vbTab + vbCrLf
- strText += "//Date: " + vbTab + System.DateTime.Now.ToString("yyyy-MM-dd HH:00:00") + vbCrLf
- strText += "//Params: " + vbTab + vbCrLf
- strText += "//Return: " + vbTab + vbCrLf
- strText += "/"
- curText.Insert(strText)
- End Sub
- End Module