RegEx or macro to modify hyperlinks
Thread poster: DZiW

DZiW
Ukraine
English to Russian
+ ...
Jun 24

Is there's a safe way in Word 2013 or WFC to change hyperlinks in the text like to ?

TY

[Edited at 2018-06-24 21:48 GMT]


 

Hans Lenting  Identity Verified
Netherlands
Member (2006)
German to Dutch
Safe Jun 25

DZiW wrote:

Is there's a safe way in Word 2013 or WFC to change hyperlinks in the text like to ?

TY

[Edited at 2018-06-24 21:48 GMT]


Are you referring to the conversion of a selected string or the conversion of a specified pattern (via a regex search)?


 

DZiW
Ukraine
English to Russian
+ ...
TOPIC STARTER
any Jun 25

Hello Hans,

It's about a conversion of the pattern: find all hyperlinks and replace with the text followed by hyperlinks in the brackets.

Why, RegEx seems quite versatile, but how?


 

Samuel Murray  Identity Verified
Netherlands
Local time: 09:38
Member (2006)
English to Afrikaans
+ ...
Visually, maybe (but visually only) Jun 25

DZiW wrote:
Is there's a safe way...


The solution at answer #1 here gets you there halfway:
https://stackoverflow.com/questions/28335564/change-display-text-of-all-hyperlinks-in-document

Then, you can use Find/Replace to change the font of the text that you don't want to be a hyperlink, so that it doesn't *look* like a hyperlink. The part that you don't want to be a hyperlink will still be a hyperlink, but it won't look like one.

So, first use this macro:

Sub UpdateDocLinks()
Dim link As Hyperlink
For Each link In ActiveDocument.Hyperlinks
link.TextToDisplay = "{{{" & link.TextToDisplay & " (}}}" & link.Address & "{{{)}}}"
Next link
End Sub

And then use this find/replace with wildcards:
Find: (\{\{\{)(*)(\}\}\})
Replace: \2
and set the style of the Replace field as e.g. Default Paragraph Font.

----------------------------------------------

1.

hgj5scsi3kehulckn51e.png

2.

(then run macro)

3.

zz6baqj1lpnxktgehwfy.png

4.

eqz3xtrktf8noz1bo0hq.png

5.

ea4iebsgy04relsezccf.png

[Edited at 2018-06-25 12:29 GMT]


 

Hans Lenting  Identity Verified
Netherlands
Member (2006)
German to Dutch
Jun 28



[Edited at 2018-06-28 21:56 GMT]


 

Samuel Murray  Identity Verified
Netherlands
Local time: 09:38
Member (2006)
English to Afrikaans
+ ...
@Hans Jun 28

Hans Lenting wrote:
The macro in this thread (I've tested the macro with Word:mac 16.14.1) converts [a plaintext URL] to a hyperlink...


I thought Dziw wanted the opposite -- convert a hyperlink into text.


 

Hans Lenting  Identity Verified
Netherlands
Member (2006)
German to Dutch
You’re right Jun 28

Samuel Murray wrote:

Hans Lenting wrote:
The macro in this thread (I've tested the macro with Word:mac 16.14.1) converts [a plaintext URL] to a hyperlink...


I thought Dziw wanted the opposite -- convert a hyperlink into text.


You’re right.


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

RegEx or macro to modify hyperlinks

Advanced search






PerfectIt consistency checker
Faster Checking, Greater Accuracy

PerfectIt helps deliver error-free documents. It improves consistency, ensures quality and helps to enforce style guides. It’s a powerful tool for pro users, and comes with the assurance of a 30-day money back guarantee.

More info »
Protemos translation business management system
Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!

The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search