Sub Puntuacion_Y_Espacios() ' Rem PASO 1. Sustituir espacios de no separación por espacios normales. Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^s" .Replacement.Text = " " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 2. Signos de puntuación que nunca pueden aparecer repetidos. With Selection.Find .Text = "([^13^l^t\,\;\:\¿\?\¡\!\«\»\“\”\‘\’\(\)\{\}\[\]]){1;}" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 3. Error cierre interrogación oexclamación seguido de punto. With Selection.Find .Text = "([\?\!])." .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 4. Signos de cierre que no llevan espacio(s) antes y llevan un espacio después. Rem PASO 4.1 Primero, nos aseguramos de que no tengan ningún espacio antes. With Selection.Find .Text = " {1;}([\»\”\’\)\]\}\?\!])" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 4.2 Segundo, nos aseguramos de que tengan al menos un espacio después. With Selection.Find .Text = "([\»\”\’\)\]\}\?\!])" .Replacement.Text = "\1 " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 4.3. Salvedad signos de cierre si van cuatro seguidos. With Selection.Find .Text = "([\»\”\’\)\]\}\?\!])( )([\»\”\’\)\]\}\?\!])( )([\»\”\’\)\]\}\?\!])( )([\»\”\’\)\]\}\?\!])( )" .Replacement.Text = "\1\3\5\7 " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 4.4. Salvedad signos de cierre si van tres seguidos. With Selection.Find .Text = "([\»\”\’\)\]\}\?\!])( )([\»\”\’\)\]\}\?\!])( )([\»\”\’\)\]\}\?\!])( )" .Replacement.Text = "\1\3\5 " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 4.5. Salvedad signos de cierre si van dos seguidos. With Selection.Find .Text = "([\»\”\’\)\]\}\?\!])( )([\»\”\’\)\]\}\?\!])( )" .Replacement.Text = "\1\3 " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 5. Signos de puntuación que no llevan espacio(s) antes y llevan un espacio después. Rem PASO 5.1 Primero, nos aseguramos de que no tengan ningún espacio antes. With Selection.Find .Text = " {1;}([\.\,\;\:])" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 5.2 Segundo, nos aseguramos de que tengan al menos un espacio después. With Selection.Find .Text = "([\.\,\;\:])" .Replacement.Text = "\1 " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 5.3 Salvedad para . , : si van entre números With Selection.Find .Text = "([0-9])([\.\,\:]) {1;}([0-9])" .Replacement.Text = "\1\2\3" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 5.4. Salvedad para : en http: With Selection.Find .Text = "(http\:) {1;}" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 6. Signos que no llevan espacio(s) después y llevan un espacio antes. Rem PASO 6.1. Primero, nos aseguramos de que no tengan ningún espacio después. With Selection.Find .Text = "([\«\“\‘\(\[\{\¿\¡]) {1;}" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 6.2. Segundo, nos aseguramos de que tengan al menos un espacio antes. With Selection.Find .Text = "([\«\“\‘\(\[\{\¿\¡])" .Replacement.Text = " \1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 6.3. Salvedad si van cuatro seguidos. With Selection.Find .Text = "( )([\«\“\‘\(\[\{\¿\¡])( )([\«\“\‘\(\[\{\¿\¡])( )([\«\“\‘\(\[\{\¿\¡])( )([\«\“\‘\(\[\{\¿\¡])" .Replacement.Text = " \2\4\6\8" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 6.4. Salvedad si van tres seguidos. With Selection.Find .Text = "( )([\«\“\‘\(\[\{\¿\¡])( )([\«\“\‘\(\[\{\¿\¡])( )([\«\“\‘\(\[\{\¿\¡])" .Replacement.Text = " \2\4\6" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 6.5. Salvedad si van dos seguidos. With Selection.Find .Text = "( )([\«\“\‘\(\[\{\¿\¡])( )([\«\“\‘\(\[\{\¿\¡])" .Replacement.Text = " \2\4" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 7. Eliminar todos los espacios redundantes. With Selection.Find .Text = "( ){1;}" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 8. Signos que no llevan espacio(s) ni antes ni después. Rem PASO 8.1. Primero, nos aseguramos de que no tengan ningún espacio antes. With Selection.Find .Text = " {1;}([^13^l^t])" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Rem PASO 8.2. Segundo, nos aseguramos de que no tengan ningún espacio después. With Selection.Find .Text = "([^13^l^t]) {1;}" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll End Sub