Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2015, 07:58 AM
grantworth grantworth is offline Search and Replace puzzle Windows 8 Search and Replace puzzle Office 2010 32bit
Novice
Search and Replace puzzle
 
Join Date: Apr 2015
Posts: 5
grantworth is on a distinguished road
Default Search and Replace puzzle


I have a long document with many url's. I want to make all of the url's italic. Is there a way to search and replace all using wildcards or some other feature?
Reply With Quote
  #2  
Old 04-06-2015, 11:13 PM
eNGiNe eNGiNe is offline Search and Replace puzzle Windows 7 32bit Search and Replace puzzle Office 2010 64bit
Expert
 
Join Date: Jan 2012
Location: Brussels [BE]
Posts: 746
eNGiNe is on a distinguished road
Default

If the URLs have been styled as Hyperlinks, something that Word intermittently manages by itself, then all you need to do is update the Hyperlink character style.
Reply With Quote
  #3  
Old 04-07-2015, 05:09 AM
grantworth grantworth is offline Search and Replace puzzle Windows 8 Search and Replace puzzle Office 2010 32bit
Novice
Search and Replace puzzle
 
Join Date: Apr 2015
Posts: 5
grantworth is on a distinguished road
Default search and replace puzzle

That worked even better than the wildcard method I was trying out. Is there also way to remove all the hyperlinks at one time (getting this document ready for InDesign)? Thanks.
Reply With Quote
  #4  
Old 04-07-2015, 05:32 AM
gmayor's Avatar
gmayor gmayor is offline Search and Replace puzzle Windows 7 64bit Search and Replace puzzle Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following macro will unlink all hyperlinks to leave the display text:

Code:
Sub UnlinkHLinks()
Dim oStory As Range
Dim oFld As field
    For Each oStory In ActiveDocument.StoryRanges
        For Each oFld In oStory.Fields
            If oFld.Type = wdFieldHyperlink Then
                oFld.Unlink
            End If
        Next oFld
        If oStory.StoryType <> wdMainTextStory Then
            While Not (oStory.NextStoryRange Is Nothing)
                Set oStory = oStory.NextStoryRange
                For Each oFld In oStory.Fields
                    If oFld.Type = wdFieldHyperlink Then
                        oFld.Unlink
                    End If
                Next oFld
            Wend
        End If
    Next oStory
    Set oStory = Nothing
lbl_Exit:
    Set oStory = Nothing
    Set oFld = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro on Search and Replace davidhuy Word VBA 1 12-19-2014 04:47 AM
Search and Replace puzzle search and replace dirkoo Word VBA 2 08-14-2013 11:25 AM
Search and Replace puzzle Odd search and replace query Rabski Word 1 11-13-2012 02:25 PM
Search Replace Copy dblack7211 Word 0 05-05-2010 01:19 PM
Search and Replace - Clear Search box JostClan Word 1 05-04-2010 08:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:08 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