Worksheet_BeforeRightClick
'查看批注主程序,找到批注所在段落位置
Dim SummaryReviewFile As Object
Dim MyPath
Dim PathName, shCMD As String
Dim pos1 As Integer
'过滤PDM/.C/.CPP/.H文件
If InStr(1, UCase(ActiveSheet.Cells(ActiveCell.Row, cnstColumnO).Value), ".C") <> 0 _
Or InStr(1, UCase(ActiveSheet.Cells(ActiveCell.Row, cnstColumnO).Value), ".H") <> 0 _
Or InStr(1, UCase(ActiveSheet.Cells(ActiveCell.Row, cnstColumnO).Value), ".CSV") <> 0 Then
msg = "来自CodeReview或PDM的检视信息不能在ReviewTool中查看批注"
MsgBox prompt:=msg, Buttons:=vbOKOnly, Title:="无法查看批注"
Exit Sub
End If
'过滤不合法的表单
If ActiveCell.Row < PrereviewTblDataBgnRow Or ActiveSheet.Cells(ActiveCell.Row, cnstColumnO).Value = "" Then
Exit Sub
End If
On Error Resume Next
PathName = ActiveWorkbook.FullName
fileToOpen = Left(ActiveWorkbook.FullName, Len(ActiveWorkbook.FullName) - Len(ActiveWorkbook.Name)) + Trim(ActiveSheet.Cells(ActiveCell.Row, cnstColumnO).Value)
Set myfile = GetObject(fileToOpen)
'如果打开文件异常出错,提示错误信息
If Err Then
MsgBox prompt:="错误信息:" & Error(Err.Number), Buttons:=vbCritical, Title:="文件操作错误"
'MsgBox prompt:=Msg, Buttons:=vbOKOnly, Title:="无法查看批注"
Err.Clear ' 清除 Err 对象字段。
Exit Sub
End If
Select Case TypeName(myfile)
Case "Document"
myfile.ActiveWindow.Visible = True
For Each Item In myfile.Comments
If Item.Scope.Start = ActiveSheet.Cells(ActiveCell.Row, cnstColumnN).Value Then
Item.Scope.paragraphs(1).Range.Select
Application.ActivateMicrosoftApp xlMicrosoftWord
Exit For
End If
Next
End Select
本文介绍了一段VBA宏代码,该宏用于检查Excel表格中的代码审查批注,并定位到具体的源文件批注位置。它通过过滤特定类型的文件(如.C、.H和.CSV),并验证表格的有效性来确保准确地定位到所需的批注。
2034

被折叠的 条评论
为什么被折叠?



