Hello, I am new to VBA in Word and I was wondering if=20
someone could help me please!

I have a string in a Word document that I want to copy=20
from Word and then copy to an Excel worksheet. But the=20
string has a hard return at the end of it. So how do I=20
copy from the beginning of the string to the hard return?=20
I know the position in the document that the string starts=20
at but I do not know how to copy only to the carriage=20
return. For examle, when you select "Show/Hide =B6" to Show=20
it looks like:

125 North Street=B6

How do I use VBA to select only up to the hard return? I=20
hope this makes sense. Any help would be appreciated.

Thanks.

Re: Text Selection with VBA by Dave

Dave
Mon Dec 06 09:15:54 CST 2004

Hi Jack,

You can use something like the following:

Dim oRng As Range
Set oRng = Selection.Range
oRng.End = oRng.Paragraphs(1).Range.End
oRng.MoveEnd Unit:=wdCharacter, Count:=-1

HTH,
Dave

"Jack" <jmuschar@comcast.net> wrote in message
news:18d501c4dba5$809c4bf0$a401280a@phx.gbl...
Hello, I am new to VBA in Word and I was wondering if
someone could help me please!

I have a string in a Word document that I want to copy
from Word and then copy to an Excel worksheet. But the
string has a hard return at the end of it. So how do I
copy from the beginning of the string to the hard return?
I know the position in the document that the string starts
at but I do not know how to copy only to the carriage
return. For examle, when you select "Show/Hide ¶" to Show
it looks like:

125 North Street¶

How do I use VBA to select only up to the hard return? I
hope this makes sense. Any help would be appreciated.

Thanks.




Re: Text Selection with VBA by Ravi

Ravi
Tue Dec 07 02:49:02 CST 2004

Hi Jack,

May be this also helpful for you.

Dim SelText As String
SelText = Selection.Text
If Selection.Characters(Len(Selection.Text)) = Chr(13) Then
Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
End If
Selection.Copy

-Ravi




"Dave Lett" wrote:

> Hi Jack,
>
> You can use something like the following:
>
> Dim oRng As Range
> Set oRng = Selection.Range
> oRng.End = oRng.Paragraphs(1).Range.End
> oRng.MoveEnd Unit:=wdCharacter, Count:=-1
>
> HTH,
> Dave
>
> "Jack" <jmuschar@comcast.net> wrote in message
> news:18d501c4dba5$809c4bf0$a401280a@phx.gbl...
> Hello, I am new to VBA in Word and I was wondering if
> someone could help me please!
>
> I have a string in a Word document that I want to copy
> from Word and then copy to an Excel worksheet. But the
> string has a hard return at the end of it. So how do I
> copy from the beginning of the string to the hard return?
> I know the position in the document that the string starts
> at but I do not know how to copy only to the carriage
> return. For examle, when you select "Show/Hide ¶" to Show
> it looks like:
>
> 125 North Street¶
>
> How do I use VBA to select only up to the hard return? I
> hope this makes sense. Any help would be appreciated.
>
> Thanks.
>
>
>
>