Jak
Tue Jun 17 05:20:01 PDT 2008
Hi Shasur
Thanks for the code. I had a slight problem in that it added the text
insertions every other line. I removed the following line:
Selection.MoveDown Unit:=wdLine, Count:=1
and it added the text to each line as required.
Many thanks for the quick reply and code, your a star.
Jak
"Shasur" wrote:
> Hi Jak
>
> Here is a hint
>
> Sub Move_Line()
>
>
> 'Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=1, Name:=""
> ' Selection.Find.ClearFormatting
> ' Selection.TypeText Text:="myArray = Array("
> '
> '
> 'Selection.TypeText Text:=", _"
> Dim TotalLines As Long
> Dim iLine As Long
> Selection.HomeKey wdStory, wdMove
>
> TotalLines = ActiveDocument.ComputeStatistics(wdStatisticLines, False)
> For iLine = 1 To TotalLines
> Selection.MoveDown Unit:=wdLine, Count:=1
> Selection.MoveStart wdLine
> Selection.MoveLeft wdCharacter, 1
> Selection.TypeText "<End Of Line>"
> Selection.MoveRight wdCharacter, 1
> If Selection.Bookmarks.Exists("\EndOfDoc") Then Exit Sub
> Next iLine
>
>
> 'Selection.MoveRight Unit:=wdWord, Count:=30, Extend:=wdExtend
>
>
> End Sub
>
> Cheers
>
>
> --
>
http://vbadud.blogspot.com
>
>
> "Jak" wrote:
>
> >
> > MS Office 2003
> >
> > Hi All
> >
> > I am putting together a macro and I am really stuck on how to get the cursor
> > to move to the end of a line in Word. I have set the cursor to go to the
> > begining of line 1 and enter some text ie.
> >
> > Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=1, Name:=""
> > Selection.Find.ClearFormatting
> > Selection.TypeText Text:="myArray = Array("
> >
> > I now need to go to the end of line 1 and then insert some text and then
> > move down a line and continue to insert the text ie
> >
> > Selection.TypeText Text:=", _"
> > Selection.MoveDown Unit:=wdLine, Count:=1
> >
> > The MoveRight ie
> >
> > Selection.MoveRight Unit:=wdWord, Count:=30, Extend:=wdExtend
> >
> > I have tried but length of the line may vary and the code would fail. Any
> > help with a loop that finds the end of line 1, enters text and then moves 1
> > line down and inserts the text until the last line is reached is what I am
> > hopeing to achieve.
> >
> > Any assistance with this would be greatly appreciated.
> >
> > Jak
> >