netian
asked on
Searching for a url and replace it with some text using Macro
Hi,
I am trying to search for a url and replace it with some text using Macro in word document.
Can some one please help me ?
Thanks,
Mobi.
I am trying to search for a url and replace it with some text using Macro in word document.
Can some one please help me ?
Thanks,
Mobi.
ASKER
Hi Graham,
I want to do it through macro. It should be an automated task when the word document loads up.
Thanks,
Mubashir.
I want to do it through macro. It should be an automated task when the word document loads up.
Thanks,
Mubashir.
This needs to go in the ThisDocument module of the document's template.
Private Sub Document_Open()
With ActiveDocument.Range.Find
.Text = "http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Word/Q_25498725.html?cid=1763"
.Replacement.Text = "Some text"
.Execute Replace:=wdReplaceAll
End With
End Sub
ASKER
Thanks Graham. But i want a regular expression that can search the text for any URL and then replace it.
Thanks,
Mobi.
Thanks,
Mobi.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Graham,
They are simple text like www.somedomain.com, and not hyperlinks in word document, i would like to use a regular expression that parses the whole text of the document and then just replaces the url with some other text.
Thanks,
Mobi.
They are simple text like www.somedomain.com, and not hyperlinks in word document, i would like to use a regular expression that parses the whole text of the document and then just replaces the url with some other text.
Thanks,
Mobi.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do Ctrl+H and put the URL in the Find box, and the new text in the Replace box.
Find: https://www.experts-exchange.com/questions/25498725/Searching-for-a-url-and-replace-it-with-some-text-using-Macro.html?cid=1763
Replace: Some text
Then click Replace or Replace All