Replace

Joined
Aug 13, 2017
Messages
6
Reaction score
0
Hello,

I got an excercise. There are 50 pages with different notion. Before the notion are this "→"  sign like → idea.
I should change this to a link → idea to <a href="idea">→ idea</a>.
Is there any chance to solve this problem with word?
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
You could use a wildcard Find/Replace, where:
Find = →(*)>
Replace = <a href=^034\1^034>^&</a>
 
Joined
Aug 13, 2017
Messages
6
Reaction score
0
Thank u! Here only doesn't workd "^&" this part so cannot put the notion.
Replace = <a href=^034\1^034>^&</a>[/QUOTE]
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
Your reply is unclear - I have no idea what you mean by "cannot put the notion".
The Find/Replace expression I posted works fine for the example you gave. Did you check the 'use wildcards' option?
 
Joined
Aug 13, 2017
Messages
6
Reaction score
0
Between the <a href></a> doesn't appear the word what I'd like to change: "→ idea".
 
Joined
Aug 13, 2017
Messages
6
Reaction score
0
In our language we use special non latin characters i.e.: á,é,í,ó, etc. Is there any sollution to change charachters between the link from á to a, é to e, í to i etc.?
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
A Find/Replace cannot change random characters in a found string - you'd have to replace them individually. You could do that before doing the href conversion or afterwards; which approach you take depends on whether you want to retain any of the non-latin characters anywhere in the <a href="idea">→ idea</a> string.
 
Joined
Aug 13, 2017
Messages
6
Reaction score
0
I tried to search internet how to use these special characters in word. I found something but I think a bit high for me.
I'd like to change any of these strings:
<a href="ideá">→ idea</a> to <a href="idea">→ idea</a> or
<a href="Ideá">→ idea</a> to <a href="idea">→ idea</a>

Can I solve this in "second step"?
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
It looks like you want to replace all the non-latin characters wherever they occur in the <a href="idea">→ idea</a> string. In that case, it would be easier to replace them before or when creating that string. You could do that with a macro like:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long, strTmp As String
Const strFnd As String = "áéíó"
Const strRep As String = "aeio"
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ChrW(&H2192) & "*>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
strTmp = LCase(Split(.Text, ChrW(&H2192))(1))
For i = 1 To Len(strFnd)
strTmp = Replace(strTmp, Mid(strFnd, i, 1), Mid(strRep, i, 1))
Next
.Text = "<a href=" & Chr(34) & strTmp & Chr(34) & ">" & ChrW(&H2192) & strTmp & "</a>"
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub

You'll notice two lines:
Const strFnd As String = "áéíó"
Const strRep As String = "aeio"
These hold the non-latin characters you want to replace and their latin equivalents, respectively. You can add more to those lists - just make sure there's a 1:1 correspondence between them. You probably need only use lower-case characters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top