Second question, sorry to be cheeky.

Whats the line of code to assign the first row of a page or first row of a
document to a variable?

Thanks

Re: Selecting first line of a page by Jean-Guy

Jean-Guy
Thu Sep 29 12:06:00 CDT 2005

Santa Claus was telling us:
Santa Claus nous racontait que :

> Second question, sorry to be cheeky.
>
> Whats the line of code to assign the first row of a page or first row
> of a document to a variable?
>
Except with Word 2003 where there is a Line collection that is kind of
difficult to use, there are no "line" object in VBA.

Would that line always be a one-line paragraph?
How would you determine the page?
What are you trying to do?


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



Re: Selecting first line of a page by Santa

Santa
Mon Oct 03 15:47:17 CDT 2005

Hi,

The code to select the first line on the current page will do. The first
line is always the heading (though not always formatted as a heading). I'm
wanting to grab this text to assign to a variable.

( I will then be using the variable as the new document name when i 'save
as').

Thanks for your help, I really do appreciate it.

"Jean-Guy Marcil" <NoSpam@LeaveMeAlone> wrote in message
news:uAqz83SxFHA.1256@TK2MSFTNGP09.phx.gbl...
> Santa Claus was telling us:
> Santa Claus nous racontait que :
>
>> Second question, sorry to be cheeky.
>>
>> Whats the line of code to assign the first row of a page or first row
>> of a document to a variable?
>>
> Except with Word 2003 where there is a Line collection that is kind of
> difficult to use, there are no "line" object in VBA.
>
> Would that line always be a one-line paragraph?
> How would you determine the page?
> What are you trying to do?
>
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
>



Re: Selecting first line of a page by Santa

Santa
Mon Oct 03 15:58:11 CDT 2005

I should have mentioned that the cursor would be on the current page that i
would be working with.


"Santa Claus" <santaclausinau@hotmail.com> wrote in message
news:434198cf$1_1@news.iprimus.com.au...
> Hi,
>
> The code to select the first line on the current page will do. The first
> line is always the heading (though not always formatted as a heading). I'm
> wanting to grab this text to assign to a variable.
>
> ( I will then be using the variable as the new document name when i 'save
> as').
>
> Thanks for your help, I really do appreciate it.
>
> "Jean-Guy Marcil" <NoSpam@LeaveMeAlone> wrote in message
> news:uAqz83SxFHA.1256@TK2MSFTNGP09.phx.gbl...
>> Santa Claus was telling us:
>> Santa Claus nous racontait que :
>>
>>> Second question, sorry to be cheeky.
>>>
>>> Whats the line of code to assign the first row of a page or first row
>>> of a document to a variable?
>>>
>> Except with Word 2003 where there is a Line collection that is kind of
>> difficult to use, there are no "line" object in VBA.
>>
>> Would that line always be a one-line paragraph?
>> How would you determine the page?
>> What are you trying to do?
>>
>>
>> --
>> Salut!
>> _______________________________________
>> Jean-Guy Marcil - Word MVP
>> jmarcilREMOVE@CAPSsympatico.caTHISTOO
>> Word MVP site: http://www.word.mvps.org
>>
>
>



Re: Selecting first line of a page by Jean-Guy

Jean-Guy
Tue Oct 04 20:20:34 CDT 2005

Santa Claus was telling us:
Santa Claus nous racontait que :

> Hi,
>
> The code to select the first line on the current page will do. The
> first line is always the heading (though not always formatted as a
> heading). I'm wanting to grab this text to assign to a variable.
>
> ( I will then be using the variable as the new document name when i
> 'save as').

Try this:

Dim ParaRange As Range
Dim StartRange As Range
Dim LineStr As String

Set StartRange = Selection.Range

Set ParaRange = ActiveDocument.Bookmarks("\Page").Range.Paragraphs(1).Range
ParaRange.Select

ParaRange.Collapse wdCollapseStart

LineStr = ActiveDocument.Bookmarks("\Line").Range.Text

MsgBox LineStr

StartRange.Select


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org