To run threw the whole document

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
 
J

Jezebel

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
 
S

Steved

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


.
 

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