Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Kontich, Vlaanderen, Belgium
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing problem with sections (Word 97-SR1)

    Hi all,

    I was looking for a way to print specific pages in a specific section in a Word-document. A quick search and the thread from <post#=233117>post 233117</post#> gave me the answer. But that thread also pointed to <post#=204230>post 204230</post#> to do things with a macro.

    I copied the macro in my multi-section document. But when testing I found that it works fine with a selection in section 1, but it failed with a selection in section 2. I enclose a picture of the error-message and also one of the VBA line that caused the error.

    Can someone help me on this one ?

    MTIA.

    Best regards,

    Walter
    Attached Images Attached Images

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

    Re: Printing problem with sections (Word 97-SR1)

    I get the same error if the final paragraph mark of the document is selected when I run that Macro.

    Replacing the line
    <font face="Georgia">Set rngEnd = ActiveDocument.Range(.End, .End)</font face=georgia>
    with
    <font face="Georgia">If Selection.End = ActiveDocument.Content.End Then
    Set rngEnd = ActiveDocument.Range(.End - 1, .End - 1)
    Else
    Set rngEnd = ActiveDocument.Range(.End, .End)
    End If
    </font face=georgia>

    Seems to give correct results

    StuartR

    Code corrected by StuartR after testing my initial, simpler, solution and finding that it failed if the selection was an insertion point before the first character of the document

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Printing problem with sections (Word 97-SR1)

    Thanks for pointing this out. I corrected the original post with a little extra code. Similar to Stuart's, but taking a different shortcut.

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

    Re: Printing problem with sections (Word 97-SR1)

    Jefferson,

    The help for Word 2002 does not have a .Range property for a document. I always use ActiveDocument.Content in this context. Your code clearly works, but do you know what ActiveDocument.Range refers to?

    StuartR

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Printing problem with sections (Word 97-SR1)

    Stuart, I never noticed that. I assume it returns the result of omitting the Start and End parameters from the .Range method. Which does seem to be the same as .Content. I'll blame my habit on Microsoft's documentation for Word 97. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  6. #6
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Kontich, Vlaanderen, Belgium
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing problem with sections (Word 97-SR1)

    Jefferson,

    I have tested your "patched" macro and it works on a testdocument.
    The only thing one must take care of is, when making a selection in the document, not to select a "manually inserted page break" (if there is one), or the next page will be in the "print-range" also.

    As I do not have my original multi-section document on hand (I am now at home and won't be in my office until next wednesday), I cannot test it on the original. But I think it will give the same result, as there are inserted page-breaks in it. I am a novice on VBA-matters, so if you could have a look at the above problem, please ?

    Thank you.

    Walter

  7. #7
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Kontich, Vlaanderen, Belgium
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing problem with sections (Word 97-SR1)

    Stuart,

    As I am at home now, and my original multi-section document (with the original macro from Jefferson attached to it) is on my office-computer, I cannot implement your solution. I will do this next wednesday.

    Please take look at my post to Jefferson, explaining a problem that came up when implementing his solution to a test-document. I am not sure if your solution covers this problem.

    Thank you.

    Walter

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

    Re: Printing problem with sections (Word 97-SR1)

    My modification to Jefferson's post also prints the next page if the selection ends with a manual page break. <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

    StuartR

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Printing problem with sections (Word 97-SR1)

    > The only thing one must take care of is, when making a selection in the document, not to select a "manually inserted page break"
    > (if there is one), or the next page will be in the "print-range" also.

    Yes, a page break seems to be a propery of the paragraph at the top of the next page. But the macro does not require such careful selection: even if you only select the first word on the page, it will print that page, so you don't need to select all the way down to the page break.

    As for how I would fix that, I'm not sure. Would take a bit of exploration, for sure.

  10. #10
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Kontich, Vlaanderen, Belgium
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing problem with sections (Word 97-SR1)

    Jefferson

    Your word of explanation did help me out. As I just need to select the first line on the page I want to be the last printed page in my selection, I (most probably) never will select the "manual page break".

    So, problem solved.

    Thank you and also Stuart for looking into it.

    Walter

Posting Permissions

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