To run threw the whole document

  • Thread starter Thread starter Steved
  • Start date Start date
S

Steved

Hello from Steved

Please how do I get the below macro to run through the
whole Document.

Thankyou.

Dim s As String
Dim p As Integer
Selection.Paragraphs(1).Range.Select
s = Selection.Text
p = InStr(1, s, " ")
p = InStr(p + 1, s, " ")
s = Right(s, Len(s) - p)
Selection.Paragraphs(1).Range.Text = s
 
Find and replace will do this. With 'Use wildcards' checked --

Find: [! ]@ [! ]@ ([!^013]@[^013])
Replace with: \1



If you really want to do it with code --

Dim pPar as Word.Paragraph
Dim s as string
Dim p as long (Don't use Integers in VB/VBA)

For each pPar in ActiveDocument.Paragraphs

s = pPar..Range.Text
p = InStr(1, s, " ")
If p > 0 then
p = InStr(p + 1, s, " ")
If p > 0 then
pPar.Range.Text = Mid$(s, p+1)
End if
End if

Next
 
Thankyou.
-----Original Message-----
Find and replace will do this. With 'Use wildcards' checked --

Find: [! ]@ [! ]@ ([!^013]@[^013])
Replace with: \1



If you really want to do it with code --

Dim pPar as Word.Paragraph
Dim s as string
Dim p as long (Don't use Integers in VB/VBA)

For each pPar in ActiveDocument.Paragraphs

s = pPar..Range.Text
p = InStr(1, s, " ")
If p > 0 then
p = InStr(p + 1, s, " ")
If p > 0 then
pPar.Range.Text = Mid$(s, p+1)
End if
End if

Next




Hello from Steved

Please how do I get the below macro to run through the
whole Document.

Thankyou.

Dim s As String
Dim p As Integer
Selection.Paragraphs(1).Range.Select
s = Selection.Text
p = InStr(1, s, " ")
p = InStr(p + 1, s, " ")
s = Right(s, Len(s) - p)
Selection.Paragraphs(1).Range.Text = s


.
 
Back
Top