【发布时间】:2015-02-06 03:17:50
【问题描述】:
我在一个文件夹中有许多 pdf 文件和一张 excel 表格。命名顺序一致。
Sheet 将被命名为 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
【问题讨论】: