Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Specifying pages in a section? (WinXP/Word2003)

    Just a quick one (I hope!) - how do I specify that I want a loop to run on all the pages in a section? that is, "for each [page] in activedocument.sections(3), do this ..."?

    Many thanks
    Beryl M


  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Beryl,

    A Page isn't an object in word. What is it that you want to do on each page, we may be able to come with a method that will work, but don't forget that just changing your default printer can change the pagination of a document.

    StuartR

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Okay - I've inherited a template that includes a section that can be as many pages long as the user wants (userbox when it opens saying how many? and user fills in number). For each page required a copy of a form (a separate document) is inserted, but the form is pretty restrictive and includes a page break - each one will definitely always be one page and the section will therefore always be the specified number of pages.

    They've now decided they want the 'print' macro to print two copies of each page in this section, but with the second half of each page blank, and I was planning to have a loop that basically said, "for each page in this section, print it once, create a white box without a border and place it over the text of the second half, print that page again then delete the box and moved on to the next page".

    However, if anyone has a better idea I'd be very pleased to hear it!!
    Beryl M


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Would it be feasible to have two instances of the form - one with the full page, the other with the lower half of the page blank?
    You could then create two copies of the document - one with the complete pages, the other with the partially blank pages. Or insert alternating copies of the two forms into one document.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Just had a thought - would it be easier if I included a section break with each insert, making each copy of the page a separate section?

    The loop would then read something like "for each section in activedocument from 3 to [section count -1], do this ..."?
    Beryl M


  6. #6
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Unfortunately not - once the document with all pages has been created, it's filled in by the user and making a second copy of each page would mean they would have to fill in the information twice.
    <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15>
    Beryl M


  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Yes,

    Including a section break would make this much easier, as you could then use For Each Section...

    StuartR

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Looping through sections is easier than looping through pages. Code could look something like this:
    Dim i As Integer
    Dim shp As Shape
    Dim sngLeft As Single
    Dim sngTop As Single
    Dim sngWidth As Single
    Dim sngHeight As Single
    With ActiveDocument.PageSetup
    sngTop = (.PageHeight - .TopMargin - .BottomMargin) / 2
    sngLeft = 0
    sngHeight = (.PageHeight - .TopMargin - .BottomMargin) / 2
    sngWidth = (.PageWidth - .LeftMargin - .RightMargin)
    End With
    For i = 1 To ActiveDocument.Sections.Count
    ActiveDocument.PrintOut Range:=wdPrintRangeOfPages, Pages:="s" & i
    Set shp = ActiveDocument.Shapes.AddShape(msoShapeRectangle, _
    sngLeft, sngTop, sngWidth, sngHeight, ActiveDocument.Sections(i).Range)
    shp.Line.Visible = False
    ActiveDocument.PrintOut Range:=wdPrintRangeOfPages, Pages:="s" & i
    shp.Delete
    Next i

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Hans,

    I think you will need to turn background printing off during this Macro, otherwise you won't have synchronised the printing with the changes, just adding
    <code>Background:= False</code>
    to the ActiveDocument.Printout line should be enough.

    StuartR

  10. #10
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Thanks Hans, that's perfect!

    <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>
    Beryl M


  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Yep, thanks! (It was air code)

  12. #12
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Hans, when I set this up and ran debug on it it complained that 'For i = 3 To' was type mismatched. This is the first few lines of my sub:

    Sub blank()
    Dim i As Integer

    For i = 3 To ActiveDocument.Sections(ActiveDocument.Sections.Co unt - 4)
    ...

    I've a feeling we're supposed to tell it what i is, aren't we? Something like:

    For activedocument.sections(i) = 3 To ActiveDocument.Sections(ActiveDocument.Sections.Co unt - 4)

    but it's not that I just tried it!

    Help!
    Beryl M


  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    i is an Integer, it is not a section, so the bold part makes it invalid:

    For i = 3 To ActiveDocument.Sections(ActiveDocument.Sections.Count - 4)

    Instead, use

    For i = 3 To ActiveDocument.Sections.Count - 4

  14. #14
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    Ah - that's better!

    Ta muchly!
    Beryl M


  15. #15
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Specifying pages in a section? (WinXP/Word2003)

    PS I know this is stupid, but I just can't find the syntax I need to get this line of code working! I want to have it set the selected row(s) of a table to non-set height, that is adjust themselves to whatever is in the cells, but I can't get the de###### to admit the right syntax! I've got

    Selection.Tables(1).Rows(1).SetHeight HeightRule:=wdRowHeightAuto

    but it just keeps telling me that SetHeight isn't optional, despite the help saying that HeightRule and one other item are options on it! The exact example in the help says:

    aTable.Rows(1).SetHeight RowHeight:=InchesToPoints(0.5), HeightRule:=wdRowHeightExactly

    and I've tried putting a comma in to allow for the (non-required) RowHeight option but that doesn't work either. <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

    Heeeeeelp!!!
    Beryl M


Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •