I have many pdfs and an excel sheet in one folder. The naming sequence is consistent.
Sheet will be named Apple. Pdfs will be named Apple_1, Apple_2
I want an excel macro to work Get the active sheet name. Hyperlink the cells in G column. When I click on text in cell 1, it should open Apple_1.pdf When I click on cell 2, it should open Apple_2.pdf. This should continue until text filled cells in that column.
I have a Word macro for the same, but I don't know how to make it work in excel. Below is the word macro.
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