Here's another macro, somewhat easier to follow and faster:

REM  *****  BASIC  *****

Option Explicit

Sub Main
Dim SearchString(16) As String
Dim ReplaceString(16) As String
SearchString=Array( "a'", "e'", "i'", "o'",_
"u''","u'", "n~", "?'",_
"!'", "A'", "E'", "I'",_
"O'", "U''","U'", "N~")
ReplaceString=Array( "á",  "é",  "í",  "ó",_
 "ü",  "ú",  "ñ",  "¿",_
 "¡",  "Á",  "É",  "Í",_
 "Ó",  "Ü",  "Ú",  "Ñ")

Dim oReplace as Object
oReplace=ThisComponent.createReplaceDescriptor()
oReplace.SearchCaseSensitive=True

Dim x As Integer
For x=LBound(SearchString()) To UBound(SearchString())
With oReplace
.SearchString=SearchString(x)
.ReplaceString=ReplaceString(x)
End With
ThisComponent.ReplaceAll(oReplace)
Next x
End Sub

Most of it was stolen from Andrew Pitonyak's macro document, revision 1126,
page 214–215.

In this case, it's important to replace u'' with ü before replacing u' with
ú. The same with U'' vs U'.
To add more possible things to replace, just add them in the arrays. Just
make sure that the search- and replace-strings end up at the same places in
their arrays. Also, the Dim lines may need to be adjusted.


Johnny Rosenberg

Reply via email to