我希望能够双击第 1 列中的任何行并打开与该行对应的另一个电子表格。我让它在一张纸上工作,但我无法弄清楚如何让它在整个工作簿上工作。请帮忙
Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim fpath As String
Dim fname As String
Dim Tname As String
Dim i As Integer
Tname = ActiveSheet.Name
If Target.Column = 1 Then
If Target.Cells.Count > 1 Then Exit Sub
i = Target.Column
fpath = "Q:\Construction\Road\Patrols\" & Tname & "\"
Select Case i
Case 1: fname = ActiveCell.Value & ".xlsx"
End Select
If Dir(fpath & fname) = vbNullString Then
MsgBox ("The file does not exist")
Else
ThisWorkbook.FollowHyperlink fpath & fname
End If
End If
End If
End Sub