跳到主要內容

如何從Word文檔中選擇和復制所有超鏈接?

在某些情況下,您有一個包含多個超鏈接的長文檔,您只需要一次從該文檔中復制所有超鏈接,然後將它們粘貼到另一個文檔中。 有什麼方法可以快速地一次復制所有這些,而不是一個一個地複制嗎?

使用VBA複製所有超鏈接

使用VBA提取所有超鏈接地址

使用Kutools for Word將所有超鏈接或僅地址複製到剪貼板好主意3


箭頭藍色右氣泡 使用VBA複製所有超鏈接

1.打開要復制超鏈接的Word文檔,然後按 Alt + F11鍵 打開 Microsoft基於Visual的應用程序窗口.

2。 點擊 插入 > 模塊,然後將以下VBA複製到窗口中。

VBA:複製所有超鏈接

Sub HyperlinksExtract()
'Updateby20140214
    Dim oLink As Hyperlink
    Dim docCurrent As Document 'current document
    Dim docNew As Document 'new document
    Dim rngStory As StoryRanges
    Set docCurrent = ActiveDocument
    Set docNew = Documents.Add
    For Each oLink In docCurrent.Hyperlinks
        oLink.Range.Copy
        docNew.Activate
        Selection.Paste
        Selection.TypeParagraph
    Next
    
    Set docNew = Nothing
    Set docCurrent = Nothing
End Sub

3。 點擊 按鈕以運行VBA代碼。 然後將所有超鏈接複製到新文檔。 您可以稍後保存新文檔。 您可以看到如下結果。

注意: 僅當所有超鏈接都用單詞鏈接時,此VBA才能運行,如果有帶有超鏈接的圖片,則此VBA代碼無法使用。


箭頭藍色右氣泡 提取所有超鏈接地址到VBA

1.打開要提取超鏈接的Word文檔,然後按 Alt + F11鍵 打開 Microsoft基於Visual的應用程序窗口.

2。 點擊 插入 > 模塊,然後將以下VBA複製到窗口中。

VBA:提取所有超鏈接地址

Function GetAllHyperlinks()
'Updateby20140214
    Dim docCurrent As Document
    Dim docNew As Document
    Dim oLink As Hyperlink
    Dim rng As Range
    Application.ScreenUpdating = False
    Set docCurrent = ActiveDocument
    Set docNew = Documents.Add
    For Each oLink In docCurrent.Hyperlinks
        Set rng = docNew.Range
        rng.Collapse
        rng.InsertParagraph
        rng.InsertAfter (oLink.Address)
    Next
    docNew.Activate
    Application.ScreenUpdating = True
    Application.ScreenRefresh
End Function

3。 點擊 按鈕以運行VBA代碼。 然後,所有超鏈接地址都提取到一個新文檔中,以後可以保存。

注意: 提取的超鏈接地址不是按原始順序。


箭頭藍色右氣泡 使用Kutools for Word將所有超鏈接或僅地址複製到剪貼板

如果您想輕鬆快速地將所有超鏈接或僅地址從Word文檔複製到剪貼板,則 複製超鏈接 的效用 Kutools for Word 可以幫你這個忙。

Kutools for Word, 與以上  方便的功能,使您的工作更加輕鬆。 

安裝後 Kutools for Word,請執行以下操作:(現在免費下載Kutools for Word!)

1。 點擊 Kutools 加 > 複製超鏈接.
doc複製超鏈接1

2.在彈出的對話框中,根據需要選擇一個選項。
doc複製超鏈接2

現在,選擇一個要放置超鏈接的位置,按 按Ctrl + V 粘貼它們。

複製和粘貼超鏈接
doc複製超鏈接3
複製並粘貼超鏈接地址
doc複製超鏈接4

分頁瀏覽和編輯多個Word文檔/ Excel工作簿,如Firefox,Chrome,Internet Explore 10!

您可能很熟悉在Firefox / Chrome / IE中查看多個網頁,並通過輕鬆單擊相應的選項卡在它們之間進行切換。 在這裡,Office選項卡支持類似的處理,使您可以在一個Word窗口或Excel窗口中瀏覽多個Word文檔或Excel工作簿,並通過單擊它們的選項卡輕鬆地在它們之間進行切換。
單擊免費試用Office選項卡!

使用Firefox在一個窗口中瀏覽多個Word文檔

相關文章:

最佳辦公生產力工具

Kutools for Word - 透過 Over 提升您的文字體驗 100 顯著特點!

🤖 Kutools 人工智慧助手:用人工智慧改變你的寫作 - 生成內容  /  重寫文字  /  總結文件  /  查詢資料 基於文檔,全部在Word中

📘 文件掌握: 分頁  /  合併文件  /  以各種格式匯出選擇(PDF/TXT/DOC/HTML...)  /  批次轉換為PDF  /  將頁面匯出為圖像  /  一次列印多個文件...

內容編輯: 批量查找和替換 跨多個文件  /  調整所有圖片的大小  /  轉置表行和列  /  將表格轉換為文字...

🧹 輕鬆清潔: 移開 多餘的空間  /  分節符  /  所有標題  /  文本框  /  超鏈接  / 如需更多拆卸工具,請前往我們的 刪除組...

創意插入: 插入 千位分隔符  /  複選框  /  單選按鈕  /  QR Code  /  條碼  /  對角線表  /  公式標題  /  圖片說明  /  表格標題  /  多張圖片  / 發現更多 插入組...

🔍 精準選擇:精確定位 特定頁面  /    /  形狀  /  標題段落  / 增強導航功能 更多 選擇功能...

星級增強: 快速導航至任何位置  /  自動插入重複文字  /  在文檔視窗之間無縫切換  /  11 轉換工具...

???? 想嘗試這些功能嗎? Kutools for Word 提供了 60天免費試用,沒有任何限制! 🚀
 
Comments (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Good information! It assisted me in extracting links from an html file I had opened in Word. Refer to <a href="https://cookieclicker2.io">cookie clicker</a> is idea new.
This comment was minimized by the moderator on the site
How can we export word file hyperlinks and it's Text display to an excel file ? 
This comment was minimized by the moderator on the site
Impresionante! Millón de gracias.Me has acercado a la solución muchísimo pero si fuera posible copiarlos en la fila 1 de un excel ya creado sería impresionante. Es para aplicarles una formula que separa los links del texto.Un saludo y un millón de gracias!!!

This comment was minimized by the moderator on the site
Thank you so much! This was exactly what I was looking for!
This comment was minimized by the moderator on the site
I am amazed. That's gold. You saved me a ton of work.
This comment was minimized by the moderator on the site
Height of Legendary, thanks a million
This comment was minimized by the moderator on the site
Can I get the same script to run in outlook?
This comment was minimized by the moderator on the site
This is great stuff! Many thanks. What changes do I need to make to GetAllHyperlinks() for the following case? -- original document contains both normal text and links -- result wanted: same document but each link is followed by a space and the URL Thanks
This comment was minimized by the moderator on the site
Excellent! It helped me extract some links from an html file that I opened with Word (Excel was discarding some links). Here is the modified code so that a csv file could be built that could be further used. [quote]SubGetAllHyperlinks() ' Updateby20160504 ' https://www.extendoffice.com/documents/word/1411-word-select-copy-all-hyperlinks.html+&cd=1&hl=en&ct=clnk&gl=us<br /> Dim docCurrent As Document Dim docNew As Document Dim oLink As Hyperlink Dim rng As Range Application.ScreenUpdating = False Set docCurrent = ActiveDocument Set docNew = Documents.Add For Each oLink In docCurrent.Hyperlinks Set rng = docNew.Range rng.InsertAfter (oLink.TextToDisplay) rng.InsertAfter (", ") rng.InsertAfter (oLink.Address) rng.InsertAfter (vbCrLf) Next docNew.Activate Application.ScreenUpdating = True Application.ScreenRefresh End Sub[/quote]
This comment was minimized by the moderator on the site
This code works fine to me. The two on examples in the article description don't. Thanks a lot and my best regards.
This comment was minimized by the moderator on the site
Thank you very much for this script. This helped me to extract 5K links. Thank you very much.
This comment was minimized by the moderator on the site
Thank you. Just what I needed to parse a document.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations