Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-23-2023, 12:21 AM
syl3786 syl3786 is offline How to export hyperlinks from Excel to Word? Windows 10 How to export hyperlinks from Excel to Word? Office 2019
Advanced Beginner
How to export hyperlinks from Excel to Word?
 
Join Date: Jan 2023
Posts: 97
syl3786 is on a distinguished road
Default How to export hyperlinks from Excel to Word?

Hi Community,

I have an Excel file containing hyperlinks addresses and the name of the hyperlinks.
(Column A are the texts, and Column B are the URLs)

I want to replace those texts in a Word Document with the hyperlinks associated with those display texts.

I wrote the below code, which can add a hyperlink to text individually. However, over 500 documents need to add hyperlinks to the texts. And each document contains at least 50 texts and needs to add hyperlinks.

Is there any method to do it faster? Your help will be much appreciated.

Code:
Sub TextFindAndHyperlink()

    Dim query As String
    Dim SearchRange As Range
    Dim SearchText As String
    Dim WebAddress As String
    
    query = InputBox("Texts to replace as hyperlinks")
        If Not query = vbNullString Then
    
    Set SearchRange = ActiveDocument.Range
    SearchText = Replace(query, " ", "+")
    
    WebAddress = InputBox("Please paste the hyperlink")
    If Not WebAddress = vbNullString Then
    
    With SearchRange.Find
        Do While .Execute(SearchText, , True, , , , True) = True
            With SearchRange
                .Hyperlinks.Add SearchRange, WebAddress
            End With
            SearchRange.Collapse wdCollapseEnd
        Loop
    
    MsgBox ("The hyperlink is added to the text")
        
    End With
    
    End If
    End If
    
End Sub

Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Word Data to Excel anifa Word 2 12-11-2022 02:51 PM
How to export hyperlinks from Excel to Word? Word form with the intent of Excel export Flyckten Word VBA 5 09-03-2018 05:34 AM
How to export hyperlinks from Excel to Word? VBA Export Data as Text from Excel to Word lwbarnes Word VBA 3 06-09-2016 02:47 PM
Through VBA, export range from Excel to Word duugg Word VBA 0 08-24-2009 07:50 PM
Word to Excel hyperlinks and spaces gak Word 1 09-14-2008 08:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft