RegEx or macro to modify hyperlinks
论题张贴者: DZiW (X)
DZiW (X)
DZiW (X)
乌克兰
English英语译成Russian俄语
+ ...
Jun 24, 2018

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
Hans Lenting
荷兰
正式会员 (自2006)
German德语译成Dutch荷兰语
Safe Jun 25, 2018

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 (X)
DZiW (X)
乌克兰
English英语译成Russian俄语
+ ...
主题发起人
any Jun 25, 2018

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
Samuel Murray  Identity Verified
荷兰
Local time: 05:31
正式会员 (自2006)
English英语译成Afrikaans南非语
+ ...
Visually, maybe (but visually only) Jun 25, 2018

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.

two

2.

(then run macro)

3.

three

4.

four

5.

five



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


 
Hans Lenting
Hans Lenting
荷兰
正式会员 (自2006)
German德语译成Dutch荷兰语
Jun 28, 2018



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


 
Samuel Murray
Samuel Murray  Identity Verified
荷兰
Local time: 05:31
正式会员 (自2006)
English英语译成Afrikaans南非语
+ ...
@Hans Jun 28, 2018

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
Hans Lenting
荷兰
正式会员 (自2006)
German德语译成Dutch荷兰语
You’re right Jun 28, 2018

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






CafeTran Espresso
You've never met a CAT tool this clever!

Translate faster & easier, using a sophisticated CAT tool built by a translator / developer. Accept jobs from clients who use Trados, MemoQ, Wordfast & major CAT tools. Download and start using CafeTran Espresso -- for free

Buy now! »
Trados Studio 2022 Freelance
The leading translation software used by over 270,000 translators.

Designed with your feedback in mind, Trados Studio 2022 delivers an unrivalled, powerful desktop and cloud solution, empowering you to work in the most efficient and cost-effective way.

More info »