2017-06-09 103 views
0

我試圖將Excel,Word或Numbers超鏈接轉換爲HTML <a>標籤。將Excel或數字(mac)超鏈接轉換爲html a標籤

例如,我有[linkName],需要 <a href='URL'>[linkName]</a>

任何想法?謝謝。

+0

您是否在每種情況下使用相同的網址或不同的網址?在每種情況下鏈接名稱是否與url相同? – Doc

+0

每種情況下都有不同的URL,並且在某些情況下,我每個單元使用兩個鏈接。 –

回答

0

經過艱苦的研究,我找到了一個可行的答案,在word或excel中,您可以創建一個新的宏並在以後運行它。

要創建宏,去「查看 - >宏」創建一個新的並粘貼此代碼:

Sub AddHREF() 
' Turn Word hyperlinks into <a href...> HTML tags 
Dim i As Integer 
For i = ActiveDocument.Hyperlinks.Count To 1 Step -1 
    With ActiveDocument.Hyperlinks(i) 
    If InStr(1, .Address, "http://www.gaebler.com", 1) Then 
     .Range = "<a href=""" & Replace(.Address, "http://www.gaebler.com", "") & """>" _ 
     & Replace(Replace(.TextToDisplay, "<strong>", ""), "</strong>", "") & "</a>" 
    Else 
     .Range = "<a href=""" & .Address & """ target=""_blank"" rel=""nofollow"">" & _ 
     Replace(Replace(.TextToDisplay, "<strong>", ""), "</strong>", "") & "</a>" 
    End If 
    End With 
    Next i 
End Sub 

然後,只需運行宏,出現神奇!