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.

Printing multiple "page 1's" of a document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Katy White - 14 Dec 2004 19:27 GMT
Hello,

I have a word document that is output from another program in RTF.  At the
top of each page, there is a page number that is not in a header or anything
and is not a field, it's just text output.  This document is not continuously
numbered from beginner to end, so there are several page 1s' in it.  I need
to be able to scroll through the document and print each page that has "Page
1 of " on it.  I have been looking at Find.Text = "" but I need to loop
through the document to the end and print each page that I need.  

Can anyone help me out? Thanks!

Katy
Dave Lett - 14 Dec 2004 20:06 GMT
Hi Katy,

If your document using sections to handle the page numbering, then you can
use something like the following:

Dim iSec As Integer
Dim sPages As String
For iSec = 1 To ActiveDocument.Sections.Count
   sPages = sPages & "p1s" & iSec & ","
Next iSec
ActiveDocument.PrintOut Range:=Left(sPages, Len(sPages) - 1)

However, it doesn't sound like the document is using sections. If you do a
find for "Page 1 of" does "Page 1 of" get selected. If so, you could use
something like the following:

With Selection
   .HomeKey Unit:=wdStory
   With .Find
       .ClearFormatting
       .Text = "Page 1 of"
       Do While .Execute
           ActiveDocument.PrintOut Range:=wdPrintCurrentPage
       Loop
   End With
End With

Hope these ideas get you started,

Dave

> Hello,
>
[quoted text clipped - 9 lines]
>
> Katy
Katy White - 14 Dec 2004 20:47 GMT
Thanks Dave, I was mostly on the track of suggestion number 2 - works great
now!

> Hi Katy,
>
[quoted text clipped - 44 lines]
> >
> > Katy
Gilley - 14 Dec 2004 21:39 GMT
Katy,

I just went through the same process as you.  I am putting my VB code below.

The main difference is that I was needing to insert a page break before each
instance of WELTON USA, LTD.  

The code is pretty simple, but it took me a while to figure out the looping.
I hope you can use some of what I have done so you don't have to spend as
much time 'tinkering' as I did.

   Dim iCount As Long
   Dim strSearch As String

     strSearch = "WELTON USA, LTD"
       iCount = 0

   With ActiveDocument.Content.Find
       .Text = "WELTON USA, LTD"
       .Format = False
       .Wrap = wdFindStop
  Do While .Execute
       iCount = iCount + 1
   Loop
   End With

   counter = 0
   Do
       
       With Selection.Find
           .Text = "WELTON USA, LTD"
           .Forward = True
           .Wrap = wdFindContinue
           .Format = False
           .MatchCase = False
           .MatchWholeWord = False
           .MatchWildcards = False
           .MatchSoundsLike = False
           .MatchAllWordForms = False
       'MsgBox (counter)
       Selection.Find.Execute
       If counter <> 0 Then
       
       Selection.HomeKey unit:=wdLine
       Selection.InsertBreak Type:=wdPageBreak
       
       End If
       Selection.EndKey unit:=wdLine
       End With
       counter = counter + 1
   Loop Until counter = iCount
   
Hope this helps,

Gilley
aka Dilbert

> Hello,
>
[quoted text clipped - 9 lines]
>
> Katy
 
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.