Reply
 
Thread Tools Display Modes
  #1   Report Post  
Steved
 
Posts: n/a
Default To goto end of document

Hello from Steved

Please how do I write a macro for the below to go to the
next and so on until it reaches the end of the document.

Dim s As String
Dim p As Integer
Selection.Paragraphs(1).Range.Select
s = Selection.Text
p = InStr(1, s, " ") ' position of 1st space
p = InStr(p + 1, s, " ") ' position of 2nd space
s = Right(s, Len(s) - p) ' text right of position
Selection.Paragraphs(1).Range.Text = s

Thankyou.

  #2   Report Post  
Greg Maxey
 
Posts: n/a
Default

Steved,

Something like:

Sub Test()
Dim s As String
Dim p As Integer
Dim pPara As Range
Dim i As Long
For i = 1 To ActiveDocument.Paragraphs.Count
Set pPara = ActiveDocument.Paragraphs(i).Range
s = pPara.Text
p = InStr(1, s, " ") ' position of 1st space
p = InStr(p + 1, s, " ") ' position of 2nd space
s = Right(s, Len(s) - p) ' text right of position
pPara.Text = s
Next
End Sub

--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Steved wrote:
Hello from Steved

Please how do I write a macro for the below to go to the
next and so on until it reaches the end of the document.

Dim s As String
Dim p As Integer
Selection.Paragraphs(1).Range.Select
s = Selection.Text
p = InStr(1, s, " ") ' position of 1st space
p = InStr(p + 1, s, " ") ' position of 2nd space
s = Right(s, Len(s) - p) ' text right of position
Selection.Paragraphs(1).Range.Text = s

Thankyou.



  #3   Report Post  
Steved
 
Posts: n/a
Default

Thankyou.

-----Original Message-----
Steved,

Something like:

Sub Test()
Dim s As String
Dim p As Integer
Dim pPara As Range
Dim i As Long
For i = 1 To ActiveDocument.Paragraphs.Count
Set pPara = ActiveDocument.Paragraphs(i).Range
s = pPara.Text
p = InStr(1, s, " ") ' position of 1st space
p = InStr(p + 1, s, " ") ' position of 2nd space
s = Right(s, Len(s) - p) ' text right of position
pPara.Text = s
Next
End Sub

--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Steved wrote:
Hello from Steved

Please how do I write a macro for the below to go to

the
next and so on until it reaches the end of the

document.

Dim s As String
Dim p As Integer
Selection.Paragraphs(1).Range.Select
s = Selection.Text
p = InStr(1, s, " ") ' position of 1st space
p = InStr(p + 1, s, " ") ' position of 2nd space
s = Right(s, Len(s) - p) ' text right of position
Selection.Paragraphs(1).Range.Text = s

Thankyou.



.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a document in a protected form CheeryNan Microsoft Word Help 5 August 1st 22 07:34 AM
Unlock portion of document Pinky Microsoft Word Help 4 October 17th 06 09:43 PM
Can you save individual document pages as seperate word files? John Calligy Mailmerge 2 April 12th 05 09:14 AM
Newbie document question please Dudley Henriques New Users 4 January 9th 05 09:38 PM
Document object in protected form Bruce Tables 2 December 6th 04 08:09 PM


All times are GMT +1. The time now is 09:24 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"