foreign characters with diacritics

D

Diane

Group,
I have a large document that contains names with foreign characters /
diacritics. I am looking for a routine that will replace the foreign accent
marks with the unaccented English character.
Any help would be appreciated!
 
D

Doug Robbins - Word MVP

I think that you may need to create a document that contains a two column
table with the characters that you want replaced in the first column and the
replacements for them in the second column then save that document and add
the path and the file name of that document inside the quotation marks in
parentheses in the following line of the following macro

Set docSource = Documents.Open("")

Dim docSource As Document, docTarget As Document
Dim tblSource As Table
Dim rngFind As Range, rngReplace As Range
Dim strFind As String, srtReplace As String
Dim arrFind As Variant, arrReplace As Variant
Dim i As Long
Set docTarget = ActiveDocument
Set docSource = Documents.Open("") 'Insert path and filename here
Set tblSource = docSource.Tables(1)
strFind = ""
strReplace = ""
With tblSource
For i = 1 To .Rows.Count - 1
Set rngFind = .Cell(i, 1).Range
Set rngReplace = .Cell(i, 2).Range
rngFind.End = rngFind.End - 1
rngReplace.End = rngReplace.End - 1
strFind = strFind & rngFind.Text & "|"
strReplace = strReplace & rngReplace.Text & "|"
Next i
Set rngFind = .Cell(.Rows.Count, 1).Range
Set rngReplace = .Cell(.Rows.Count, 2).Range
rngFind.End = rngFind.End - 1
rngReplace.End = rngReplace.End - 1
strFind = strFind & rngFind.Text
strReplace = strReplace & rngReplace.Text
End With
docSource.Close wdDoNotSaveChanges
arrFind = Split(strFind, "|")
strReplace = Split(strReplace, "|")
docTarget.Activate
For i = 0 To UBound(arrFind)
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=arrFind(i), Forward:=True,
MatchWholeWord:=False, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) =
True
Selection.Range.Text = arrReplace(i)
Selection.Collapse wdCollapseEnd
Loop
End With
Next i

Then, when you run that macro with the document containing the characters
that you want replaced as the active document, it should do what you want.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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