Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Opening a document in a protected form | Microsoft Word Help | |||
Unlock portion of document | Microsoft Word Help | |||
Can you save individual document pages as seperate word files? | Mailmerge | |||
Newbie document question please | New Users | |||
Document object in protected form | Tables |