Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing pages with AutoShapes (Word 2000)

    Is there a way to print only the pages of a document that contain at least one AutoShape? How do you even search to an AutoShape?

  2. #2
    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 pages with AutoShapes (Word 2000)

    There's a special code to search for graphics (^g) but it doesn't seem to notice AutoShape objects.

    You can get a Shape's anchor's page number, which might be just as good as the Shape's page number. Here's an example that just drops a list in the Immediate window:

    Sub ShapeListPageNumbers()
    Dim aShape As Shape
    For Each aShape In ActiveDocument.Shapes
    Debug.Print aShape.Name, aShape.Anchor.Information(wdActiveEndPageNumber)
    Next
    If Not (aShape Is Nothing) Then Set aShape = Nothing
    End Sub

    But it's not limited to AutoShapes per se and will include, for example, bitmaps in the drawing layer. You could interrogate the Shape's properties, but that is a bit beyond my knowledge. Hope this helps.

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

    Re: Printing pages with AutoShapes (Word 2000)

    To restrict this code to Autoshapes, you could add the lines
    <font face="Georgia">
    If aShape.Type = msoAutoShape Then
    End If
    </font face=georgia>

    At the appropriate places.

    StuartR

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing pages with AutoShapes (Word 2000)

    Many thanks to jscher2000 and Stuart for the code! I finally had a chance to give it a good test, and this is indeed what I was looking for. To restrict the code to AutoShapes (at least the ones in my particular documents), I needed to change Stuart's code to:
    If aShape.Type = msoFreeform Then
    End If

    I'm going to use this code in a macro to print only the pages with AutoShapes. If I have problems (or success!), I'll let you know! Thank you very much for your help.

    - Linda

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing pages with AutoShapes (Word 2000)

    I'm struggling a bit with trying to write a macro to print out only the pages with AutoShapes. Two questions:

    First, the code

    aShape.Anchor.Information(wdActiveEndPageNumber)

    returns what I call the "relative" page number of the document. That's the page number counting consecutively from the top of the document, not accounting for sections or page numbers that you set. (This is the page number that shows in the status bar next to the total number of pages, such as 8/22.) Can I actually use these "relative" page numbers in the PrintOut method or whatever method I can use to print?

    Second, I am using the following code to print:

    ActiveDocument.PrintOut Pages:=strPagesToPrint

    In my test, strPagesToPrint is equal to "10, 5, 7, 8, 9" (these are "relative" page numbers). Unfortunately, running this code causes the entire document to print!

    Can someone rescue me (again)? Thanks!

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

    Re: Printing pages with AutoShapes (Word 2000)

    The syntax you need is
    <font face="Georgia">ActiveDocument.PrintOut Pages:=strPagesToPrint, Range:=wdPrintRangeOfPages</font face=georgia>

    StuartR

  7. #7
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing pages with AutoShapes (Word 2000)

    Thank you, Stuart! Yes, that worked to print just the pages I requested. However, I still have one (major) problem left. The pages the macro prints are not the ones with AutoShapes because I'm feeding the PrintOut method the "relative" page numbers returned by aShape.Anchor.Information(wdActiveEndPageNumber), and the PrintOut method is apparently using the page numbers set in the document. That is, the relative page 7/22 containing an AutoShape is set as page 3, and feeding 7 to the PrintOut method prints page 11/22, which has a value of 7. Any ideas on how to reconcile the two?

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

    Re: Printing pages with AutoShapes (Word 2000)

    Instead of wdActiveEndPageNumber, you should be using wdActiveEndSectionNumber and wdActiveEndAdjustedPageNumber to build a string that looks like "S1P3, S1P5, S2P4" etc.

    Have a look at the help for Selection.Information or use the browser to look at the possible values for wdInformation

    StuartR

  9. #9
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing pages with AutoShapes (Word 2000)

    Thank you, Stuart! It worked, and I think I can actually finish this macro now. My sincere thanks!

    - Linda

Posting Permissions

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