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 / December 2004

Tip: Looking for answers? Try searching our database.

Selecting a page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 07 Dec 2004 18:56 GMT
Would someone be able to tell me how to select a range on
a specific page in a word document. For example I am using
one of the following to select text from a word document:

1) Set Vendorname = ActiveDocument.Range(Start:=108,  
  End:=149)

2) Set VendorLine1 = appWrd.ActiveDocument.Range
 (Start:=205, End:=206)
 VendorLine1.End = VendorLine1.Paragraphs(1).Range.End
 VendorLine1.MoveEnd Unit:=wdCharacter, Count:=-1

However, I am not able to select this on anything but the
first page. How can I use VBA to say I want this from
another page?

Thanks!!
Ed - 07 Dec 2004 23:06 GMT
Jack:  What I wound up doing one time was using
Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, _
       Count:=PgNo
You can set your "PgNo" variable with a UserForm or Input Box.  Then use
PgNo+1 to take you to the first character position of the next page.

With this (keep in mind I haven't done this personally), you could set a
bookmark("Mark1", let's say) at the first position, and set another bookmark
("Mark2") at the second position.  Now set a range between the two
bookmarks:
Set rng = ActiveDocument.Range _
   (Start:= ActiveDocument.Bookmarks("Mark1").End, _
    End:= ActiveDocument.Bookmarks("Mark2").Start)

Hope it works for you.
Ed

> Would someone be able to tell me how to select a range on
> a specific page in a word document. For example I am using
[quoted text clipped - 13 lines]
>
> Thanks!!
Jack - 08 Dec 2004 04:20 GMT
Thanks, I got the part about using the "PgNo", but now
how do I make a bookmark on the page I select? Sorry but
I am new to Word VBA.

>-----Original Message-----
>Jack:  What I wound up doing one time was using
[quoted text clipped - 33 lines]
>
>.
Ed - 08 Dec 2004 13:29 GMT
   ActiveDocument.Bookmarks.Add Name:="Mark1"

Two things to help you learn more:
(1) The F1 key:  brings up the Help files, which often have code examples.
As you're typing in code, set the cursor in the name of the object,
property, or method you want to learn more about and press F1.  It will
bring up the Help topic for that item, and usually give you associated items
as well.
(2)  Google search the newsgroups.  Just about every question has been
answered there before.  (Where do you think I get half my code?   8>)     )

HTH
Ed

> Thanks, I got the part about using the "PgNo", but now
> how do I make a bookmark on the page I select? Sorry but
[quoted text clipped - 46 lines]
> >
> >.
Christian =?iso-8859-1?Q?Fre=DFdorf?= - 08 Dec 2004 13:40 GMT
Hi Jack,

> Would someone be able to tell me how to select a range on
> a specific page in a word document. For example I am using
> one of the following to select text from a word document:

Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, _
       Count:=PageNo
Selection.Bookmarks("\Page").Select

Signature

regards Christian
~~~~~~~~~~~~~~~~
reply only to this newsgroup
http://www.mvps.org/word/FindHelp/Posting.htm
http://support.microsoft.com/default.aspx?scid=fh;DE;NGNetikette

Ed - 08 Dec 2004 17:34 GMT
Wow!  A bookmark that ALREADY contains the current page?!?  I wish I had
read a bit more a year ago!  Thank you, Christian, for helping both Jack and
me!

Ed

> Hi Jack,
>
[quoted text clipped - 5 lines]
>         Count:=PageNo
> Selection.Bookmarks("\Page").Select
Jack - 08 Dec 2004 17:49 GMT
Yes,
Thanks!!

But how ,specificaly, would I add a bookmark on say Page 5
that starts say at character 180 and goes to 200?

>-----Original Message-----
>Wow!  A bookmark that ALREADY contains the current page?!?  I wish I had
[quoted text clipped - 4 lines]
>
>"Christian Freßdorf" <ungueltig@nurfuerspam.de> wrote in
message
>news:1t08ein36lh86.dlg@zaphod-systems.de...
>> Hi Jack,
[quoted text clipped - 8 lines]
>
>.
Jean-Guy Marcil - 08 Dec 2004 20:26 GMT
Jack was telling us:
Jack nous racontait que :

> Yes,
> Thanks!!
>
> But how ,specificaly, would I add a bookmark on say Page 5
> that starts say at character 180 and goes to 200?

Do you mean (1) the 180th charcter in the document (Which happens to be on
page 5) or (2) the 180th character on page 5?

(1)
'_______________________________________
Sub DocBookMark()

Dim MyRange As Range

With ActiveDocument
   Set MyRange = .Range(Start:=.Characters(180).Start, _
       End:=.Characters(200).End)
   .Bookmarks.Add Name:="Test", Range:=MyRange
End With

End Sub
'_______________________________________

or
(2)
'_______________________________________
Sub PageBookMark()

Dim MyRange As Range
Dim CurrentRange As Range

'To save user selection
Set CurrentRange = Selection.Range
Selection.GoTo wdGoToPage, wdGoToAbsolute, 5

Set MyRange = Selection.Bookmarks("\page").Range

With MyRange
   If .Characters.Count > 198 Then
       .MoveEnd wdCharacter, 199 - .Characters.Count
       .MoveStart wdCharacter, 179
       .Bookmarks.Add Name:="Test", Range:=MyRange
   Else
       MsgBox "Too few charcters on target page to " _
           & "create bookmark.", vbExclamation, "Cancelled"
   End If
End With

'Replace user original selection
CurrentRange.Select

End Sub
'_______________________________________

Signature

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

Christian =?iso-8859-1?Q?Fre=DFdorf?= - 10 Dec 2004 06:54 GMT
Hi Jack,

> But how ,specificaly, would I add a bookmark on say Page 5
> that starts say at character 180 and goes to 200?

ok, take the complete page 5 into a range and adjust the range starting and
ending values. Add a bookmark to this reduced range:

Sub Test()
Dim rng As Range
Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, _
       Count:=5
Set rng = Selection.Bookmarks("\Page").Range
rng.SetRange 180, 200
rng.Select
ActiveDocument.Bookmarks.Add "MyTest", rng
End Sub

HTH
Signature

regards Christian
~~~~~~~~~~~~~~~~
reply only to this newsgroup
http://www.mvps.org/word/FindHelp/Posting.htm
http://support.microsoft.com/default.aspx?scid=fh;DE;NGNetikette

Renjith - 10 Dec 2004 07:45 GMT
Hi there,

 I have tried this. It is capturing the whole page, but the problem is that
if my document contains a Section Break towards the end of the page, then it
becomes a Page Break. how can I solve this probelm?
 Also I would like to get the font type and size of the Bullets in a
particular doc file.

Thanks and Regards,
Renjith R Nair

"Christian Freßdorf" wrote:

> Hi Jack,
>
[quoted text clipped - 15 lines]
>
> HTH
Renjith - 09 Dec 2004 01:39 GMT
Hi,
 Does any body has idea how to save Individual Pages at random from an MS
Word file without any changes in the Formatting. Also, how can I get the Font
Type and Style for Bullets and Numbering on a particular file. Can someone
help me?

> Would someone be able to tell me how to select a range on
> a specific page in a word document. For example I am using
[quoted text clipped - 13 lines]
>
> Thanks!!
 
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.