My document has four lines of text.
Each line ends with a paragraph mark.
How do I select the first line and assign it to string variable sItem1
select the second line and assign it to string variable sItem2
select the third line and assign it to string variable sItem3
select the fourth and assign it to string variable sItem4?

I'm new to vba for word 2002 and any pointers in the right direction will be
most appreciated.



--
Regards,
David

Re: select text and assign to variable by Doug

Doug
Sat Aug 07 18:38:38 CDT 2004

Hi David,

Dim sItem1 As String, sItem2 As String, sItem3 As String, sItem4 As String,
Item As String
With ActiveDocument
sItem1 = .Paragraphs(1).Range.Text
sItem2 = .Paragraphs(2).Range.Text
sItem3 = .Paragraphs(3).Range.Text
sItem4 = .Paragraphs(4).Range.Text
End With

See the article "Getting To Grips With VBA Basics In 15 Minutes" at:

http://word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm

and other information on that site.
--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"fitful_thought" <cascando@legs.com> wrote in message
news:uIkIvINfEHA.1764@TK2MSFTNGP10.phx.gbl...
> My document has four lines of text.
> Each line ends with a paragraph mark.
> How do I select the first line and assign it to string variable sItem1
> select the second line and assign it to string variable sItem2
> select the third line and assign it to string variable sItem3
> select the fourth and assign it to string variable sItem4?
>
> I'm new to vba for word 2002 and any pointers in the right direction will
> be
> most appreciated.
>
>
>
> --
> Regards,
> David
>
>



Re: select text and assign to variable by fitful_thought

fitful_thought
Sat Aug 07 19:59:36 CDT 2004

Doug,

Thank you for your help.

David

"Doug Robbins" <dkr@NOmvpsSPAM.org> wrote in message
news:%23xEereNfEHA.3988@tk2msftngp13.phx.gbl...
> Hi David,
>
> Dim sItem1 As String, sItem2 As String, sItem3 As String, sItem4 As
String,
> Item As String
> With ActiveDocument
> sItem1 = .Paragraphs(1).Range.Text
> sItem2 = .Paragraphs(2).Range.Text
> sItem3 = .Paragraphs(3).Range.Text
> sItem4 = .Paragraphs(4).Range.Text
> End With
>
> See the article "Getting To Grips With VBA Basics In 15 Minutes" at:
>
> http://word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm
>
> and other information on that site.
> --
> Please respond to the Newsgroup for the benefit of others who may be
> interested. Questions sent directly to me will only be answered on a
paid
> consulting basis.
>
> Hope this helps,
> Doug Robbins - Word MVP
> "fitful_thought" <cascando@legs.com> wrote in message
> news:uIkIvINfEHA.1764@TK2MSFTNGP10.phx.gbl...
> > My document has four lines of text.
> > Each line ends with a paragraph mark.
> > How do I select the first line and assign it to string variable sItem1
> > select the second line and assign it to string variable sItem2
> > select the third line and assign it to string variable sItem3
> > select the fourth and assign it to string variable sItem4?
> >
> > I'm new to vba for word 2002 and any pointers in the right direction
will
> > be
> > most appreciated.
> >
> >
> >
> > --
> > Regards,
> > David
> >
> >
>
>