跳到主要內容

如何在Excel中一次更改多個超鏈接路徑?

出於某種目的,您可以為工作表中的數據創建多個超鏈接,並且所有超鏈接都鏈接到相同的文件路徑或地址,但是現在,您需要一次用另一個地址替換該超鏈接路徑。 單獨更改超鏈接的路徑可能會浪費大量時間,是否有解決此問題的快速方法?

使用VBA代碼一次更改工作表中的多個超鏈接路徑

一次更改工作表/工作簿/多個工作表/選擇中的多個超鏈接路徑,並具有驚人的功能


使用VBA代碼一次更改工作表中的多個超鏈接路徑

假設您具有與以下屏幕快照相同的超鏈接數據列表,並且具有VBA代碼,則可以使用新的VBA代碼快速替換工作表中的舊文件路徑或地址。

1. 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic應用程序窗口.

2. 點擊 插入 > 模塊,然後將以下宏粘貼到 模塊窗口.

VBA代碼:一次更改多個超鏈接路徑

Sub ReplaceHyperlinks()
'Updateby Extendoffice
Dim Ws As Worksheet
Dim xHyperlink As Hyperlink
Dim xOld As String, xNew As String
xTitleId = "KutoolsforExcel"
Set Ws = Application.ActiveSheet
xOld = Application.InputBox("Old text:", xTitleId, "", Type:=2)
xNew = Application.InputBox("New text:", xTitleId, "", Type:=2)
Application.ScreenUpdating = False
For Each xHyperlink In Ws.Hyperlinks
    xHyperlink.Address = Replace(xHyperlink.Address, xOld, xNew)
Next
Application.ScreenUpdating = True
End Sub

3。 然後按 F5 鍵以運行此代碼,並在提示框中輸入您的舊超鏈接地址到 舊文字 框。 看截圖:

4。 點擊 OK,然後會彈出另一個提示框,提醒您輸入要使用的新超鏈接地址。

5。 然後點擊 OK,所有相同的舊超鏈接地址立即被新的替換。 查看屏幕截圖:


一次更改工作表/工作簿/多個工作表/選擇中的多個超鏈接路徑,並具有驚人的功能

如果要替換選區,多個工作表,當前工作簿或多個工作簿中的超鏈接路徑,該怎麼辦? 用 查找和替換 的特點 Excel的Kutools,您可以快速處理此任務。

注意:要應用此 查找和替換 實用程序,首先,您應該下載 Excel的Kutools,然後快速輕鬆地應用該功能。

安裝後 Excel的Kutools,請這樣做:

1。 點擊 庫工具 > 導航,請參見屏幕截圖:

2。 在開 導航 窗格中單擊 查找和替換 標籤,在 查找和替換 窗格中單擊 更換 標籤,然後執行以下操作:

  • 將您要查找的舊超鏈接文本輸入到 查找內容 文本框,然後在其中鍵入您要替換的新超鏈接文本。 更換 文本框;
  • 指定您要查找的範圍並從中替換超鏈接路徑 下拉列表;
  • 然後,從“查找範圍”下拉列表中選擇“超鏈接”;
  • 最後點擊 找到所有 按鈕,包含特定超鏈接文本的所有相應單元格都已列在底部列錶框中。

3。 然後,點擊 “全部替換” 按鈕,舊的超鏈接路徑已立即更改為新的,請參見屏幕截圖:

點擊下載Kutools for Excel免費試用!


更多相關文章:

  • 從超鏈接中提取實際地址
  • 假設您有一個包含超鏈接的單元格區域,現在您需要查看超鏈接的實際目的地,並從超鏈接中提取它們,如下面的屏幕截圖所示。 有沒有簡單的方法可以快速解決此問題?
  • 在Excel中將圖像URL轉換為實際圖像
  • 如果現在在A列中有一個圖像URL地址列表,那麼您想從URL下載相應的圖片,並將它們顯示在相鄰的B列中,如左圖所示。 在Excel中,如何快速,輕鬆地從圖像URL中提取實際圖片?
  • 在Excel中將網址文本轉換為可點擊的超鏈接
  • 假設您的工作表中有多個URL,但是它們沒有鏈接,現在您需要將所有未鏈接的URL轉換為可單擊的超鏈接,如下面的屏幕快照所示。 當然,您可以雙擊它們一次以使其可單擊,但是如果有很多URL,這將很耗時。 如何在Excel中自動將多個未鏈接的URL轉換為可單擊的超鏈接?
  • 從Excel超鏈接打開PDF文檔的特定頁面
  • 將單元格鏈接到PDF文件時,通常,單擊以打開超鏈接時,將轉到PDF文件的第一頁。 如果您需要通過單擊超鏈接直接跳到PDF文件的特定頁面,則本文可能會對您有所幫助。

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (47)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
This might be an older article, but was exactly what I needed. Thank you!
This comment was minimized by the moderator on the site
hi
thanks man you helped me a lot
This comment was minimized by the moderator on the site
I downloaded this and gave it a try and it did nothing. My hyperlinks look like this: file///\\server\shared\PO\CY2021\25079.pdf. I'm trying to change "server" to "server1" after a migration. I do the find/replace and choose Hyperlink, execute it, and... nothing happens. 
Any ideas?
This comment was minimized by the moderator on the site
Hello John,Sorry to hear that. The reason why the find/replace function didn't work is that your hyperlink file///\\server\shared\PO\CY2021\25079.pdf is not valid. According to the Excel dialog box, it shows the address of this site is not valid. Check the address and try again.
Then when I change your hyperlink to http://file///\\server\shared\PO\CY2021\25079.pdf, the find/replace function works perfectly. Please have a try. Have a nice day.
Sincerely,Mandy
This comment was minimized by the moderator on the site
Muchas gracias, me ahorraste mucho tiempo actualizando hipervinculos!
This comment was minimized by the moderator on the site
Muito obrigado! Você me salvou dezenas de horas de sono que seriam perdidas atualizando links.
This comment was minimized by the moderator on the site
Would it be possible to have a version to set a macro in power point for update links to excel, happens that monthly we need to link the power point presentation to a new excel in a new location. I have to do it one by one and it takes hours! MANY THANKS!!!!

This comment was minimized by the moderator on the site
Thankyou so much for the vba fix. I knew there had to be an easy way to fix my hyperlink problem and you provided it :) I am extremely grateful.
This comment was minimized by the moderator on the site
Many thanks for the VBA code to change multiple hyperlink paths at once. Would it be possible to have a version that would go through the different tabs (worksheets) of the xls workbook, as the current version only seems to change the links in the active worksheet? Would be highly appreciated!

Thanks,

Schweppy
This comment was minimized by the moderator on the site
Hello, Schweppy,
The below code can help you to replace the hyperlinks in all sheets, please try.

Sub ReplaceHyperlinks()
Dim xWs As Worksheet
Dim xWss As Sheets
Dim xHyperlink As Hyperlink
Dim xOld As String, xNew As String
xTitleId = "KutoolsforExcel"
Set WS = Application.ActiveSheet
xOld = Application.InputBox("Old text:", xTitleId, "", Type:=2)
xNew = Application.InputBox("New text:", xTitleId, "", Type:=2)
Application.ScreenUpdating = False
Set xWss = Application.ActiveWorkbook.Worksheets
For Each xWs In xWss
For Each xHyperlink In xWs.Hyperlinks
xHyperlink.Address = Replace(xHyperlink.Address, xOld, xNew)
Next
Next xWs
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
This is amazing!!! Thank you for posting the code that works for all of the worksheets. I had the hardest time finding this and couldn't figure out how to create it myself. Thank you so much for sharing your code with the world!!!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Your code helped me update hundreds of hyperlinks in a blink of an eye. Thank you soo much for you help.
This comment was minimized by the moderator on the site
Thanks a lot, works perfectly fine. Highly appreciated.
This comment was minimized by the moderator on the site
Glad it helps. Any questions, please feel free to contact us. Have a nice day!
This comment was minimized by the moderator on the site
Many thanks for the VBA code to change multiple hyperlink paths at once. Would it be possible to have a version that would go through the different tabs (worksheets) of the xls workbook, as the current version only seems to change the links in the active worksheet? Would be highly appreciated!

Thanks,

Schweppy
This comment was minimized by the moderator on the site
Had a spreadsheet with over 200 items that had hyperlinks that needed to be edited. This just saved me SO MUCH TIME. THANK YOU!!
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