0
我在一个文件夹中有许多pdf和excel工作表。命名顺序一致。超链接列= Excel宏
工作表将被命名为Apple。 Pdfs将被命名为Apple_1,Apple_2
我想要一个excel宏来工作 获取活动工作表名称。 超链接G列中的单元格。 当我单击单元格1中的文本时,它应该打开Apple_1.pdf 当我单击单元格2时,它应该打开Apple_2.pdf。 这应该继续,直到文本填充该列中的单元格为止。
我有一个相同的Word宏,但我不知道如何使它在Excel中工作。以下是宏词。
Sub macro3()
Dim tbl As Table
Dim coll As Column
Dim path As String
Dim pdf As String
Dim path1 As String
pdfname = ActiveDocument.Name
pdfname = Left(pdfname, Len(pdfname) - 4)
pdfname = Replace(pdfname, " ", "_")
Set tbl = ActiveDocument.Tables(1)
Set coll = tbl.Columns(7)
Set colpdf = tbl.Columns(7)
i = 0
For Each c In coll.Cells
If (i <> 0 And InStr(c, ".pdf") > 0) Then
path1 = pdfname & "_" & i & ".pdf"
ActiveDocument.Hyperlinks.Add Anchor:=c.Range, Address:=path1
End If
i = i + 1
Next
End Sub