Visual Basic - Eliminar espacios en word

Life is soft - evento anual de software empresarial
 
Vista:

Eliminar espacios en word

Publicado por Geo (2 intervenciones) el 09/01/2012 19:39:58
Hola, que tal.
Bueno, tengo un documento en word que contiene un listado de varias oraciones los cuales no terminan en punto necesariamente y el espacio entre ellas es variado. Y me gustaría ordenarlas de modo tal que al comienzo cada una tenga un guion y el espaciado entre ellas sea uniforme, de un espacio solamente. Por ejemplo si la entrada es:

one swallow does not a summer make.

the first step is always the hardest



forewarned is forearmed
A friend in need is a friend indeed


man does not live by bread alone



When the cat's away, the mice play.

You can't teach an old dog new tricks


charity begins at home.
Clothes do not make the man

you have to take the good with the bad.
--------------------------------------

La salida sea:

- One swallow does not a summer make.
- The first step is always the hardest.
- Forewarned is forearmed.
- A friend in need is a friend indeed.
- Man does not live by bread alone.
- When the cat's away, the mice play.
- You can't teach an old dog new tricks.
- Charity begins at home.
- Clothes do not make the man.
- You have to take the good with the bad.

----------------------------------------

Es decir, que al final cada oración tenga un punto, al comienzo un guión y que estén ordenadas alfabeticamente por la primera letra. Les agradezco cualquier ayuda que puedan ofrecerme. Gracias por su atención.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 119
Ha disminuido 1 puesto en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

Eliminar espacios en word

Publicado por Christian (713 intervenciones) el 13/01/2012 16:58:45
Private Sub Command1_Click()
Dim a As New Collection
a.Add (AddPoint("one swallow does not a summer make."))
a.Add (AddPoint("the first step is always the hardest"))
a.Add (AddPoint("forewarned is forearmed"))
a.Add (AddPoint("A friend in need is a friend indeed"))
a.Add (AddPoint("man does not live by bread alone"))
a.Add (AddPoint("When the cat's away, the mice play."))
a.Add (AddPoint("you can 't teach an old dog new tricks"))
a.Add (AddPoint("charity begins at home."))
a.Add (AddPoint("Clothes do not make the man"))
a.Add (AddPoint("you have to take the good with the bad."))

Call SortCollection(a)

For i = 1 To a.Count
Debug.Print a(i)
Next

End Sub
Public Function AddPoint(Text As String) As String
If Trim(Right(Text, 1)) = "." Then
AddPoint = UCase(Mid(Trim(Text), 1, 1)) & Mid(Trim(Text), 2)
Else
AddPoint = UCase(Mid(Trim(Text), 1, 1)) & Mid(Trim(Text), 2) & "."
End If
End Function
Public Sub SortCollection(ColVar As Collection)
Dim oCol As Collection
Dim i As Integer
Dim i2 As Integer
Dim iBefore As Integer
If Not (ColVar Is Nothing) Then
If ColVar.Count > 0 Then
Set oCol = New Collection
For i = 1 To ColVar.Count
If oCol.Count = 0 Then
oCol.Add ColVar(i)
Else
iBefore = 0
For i2 = oCol.Count To 1 Step -1
If LCase(ColVar(i)) < LCase(oCol(i2)) Then
iBefore = i2
Else
Exit For
End If
Next
If iBefore = 0 Then
oCol.Add ColVar(i)
Else
oCol.Add ColVar(i), , iBefore
End If
End If
Next
Set ColVar = oCol
Set oCol = Nothing
End If
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Eliminar espacios en word

Publicado por Geo (2 intervenciones) el 14/01/2012 04:33:15
Hola Christian, gracias por responder. He probado el codigo en el word, pero no sucede nada. ¿Que podria estar pasando? Por cierto, el archivo que tengo contiene muchas mas oraciones, unas quinientas cincuenta mas o menos. Ojala puedas hecharme una mano. Igual muchas gracias por tu tiempo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar