Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2005

Tip: Looking for answers? Try searching our database.

Selecting first line of a page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Santa Claus - 29 Sep 2005 12:52 GMT
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
Jean-Guy Marcil - 29 Sep 2005 18:06 GMT
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?

Signature

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

Santa Claus - 03 Oct 2005 21:47 GMT
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.

> Santa Claus was telling us:
> Santa Claus nous racontait que :
[quoted text clipped - 10 lines]
> How would you determine the page?
> What are you trying to do?
Santa Claus - 03 Oct 2005 21:58 GMT
I should have mentioned that the cursor would be on the current page that i
would be working with.

> Hi,
>
[quoted text clipped - 21 lines]
>> How would you determine the page?
>> What are you trying to do?
Jean-Guy Marcil - 05 Oct 2005 02:20 GMT
Santa Claus was telling us:
Santa Claus nous racontait que :

> Hi,
>
[quoted text clipped - 4 lines]
> ( 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

Signature

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.