|
5#
楼主 |
发表于 2008-11-13 10:36:05
|
只看该作者
Private Sub Workbook_Open()
Dim S, I As Integer
S = Me.Worksheets.Count
Sheet1.Activate '需加这句,否则目录将会出现在关闭时作激活的工作表上
Sheet1.Cells(1, 1) = "序号"
Sheet1.Cells(1, 2) = "名称"
For I = 1 To S - 1
Range("B" & I + 1).Hyperlinks.Add Anchor:=Range("B" & I + 1), Address:="", SubAddress:=ThisWorkbook.Sheets(I).Name + "!A1"
Sheet1.Cells(I + 1, 1) = I
Sheet1.Cells(I + 1, 2) = Me.Sheets(I).Name
Next I
End Sub
=====================================================
以上代码可以解决自动生成目录并链接到对应的Sheet
但是当工作表的名字中有特殊字符的时候其对应的超链接就会出错,那位大虾可以帮我解决啊?
为何还没人帮我解决?
Sheet1.Activate '需加这句,否则目录将会出现在关闭时作激活的工作表上(见事例) |
|