Print pages with figures only

B

Bivragh

Hi, I wanted to know is there any way to print pages only with figures or
tables in a large document. I dont want to select indivual page containing
figures instead give a general command to print all in one go.

Regards

Bivragh
 
J

Jay Freedman

Hi, I wanted to know is there any way to print pages only with figures or
tables in a large document. I dont want to select indivual page containing
figures instead give a general command to print all in one go.

Regards

Bivragh

It ain't easy... Try this macro for printing only pages with graphics
(see http://www.gmayor.com/installing_macro.htm if needed):

Sub PrintPicturePages()
Dim oldTarget As WdBrowseTarget
Dim strPages As String
Dim prevPgSec As String
Dim lastPgSec As String

oldTarget = Application.Browser.Target
Selection.EndKey Unit:=wdStory, Extend:=False
lastPgSec = CurrPgSec
Selection.HomeKey Unit:=wdStory, Extend:=False
Do
' jump to next graphic (may not move)
Application.Browser.Target = wdBrowseGraphic ' <===
Application.Browser.Next

If CurrPgSec <> prevPgSec Then
strPages = strPages & CurrPgSec & ","
prevPgSec = CurrPgSec
End If

If Len(strPages) > 100 Then
'remove last comma
strPages = Left(strPages, Len(strPages) - 1)
ActiveDocument.PrintOut Background:=False, _
Range:=wdPrintRangeOfPages, _
Pages:=strPages
strPages = ""
End If

' jump to next page
Application.Browser.Target = wdBrowsePage
Application.Browser.Next
prevPgSec = CurrPgSec
Loop Until CurrPgSec = lastPgSec

If Len(strPages) > 0 Then
'remove last comma
strPages = Left(strPages, Len(strPages) - 1)
ActiveDocument.PrintOut Background:=False, _
Range:=wdPrintRangeOfPages, _
Pages:=strPages
End If

Application.Browser.Target = oldTarget
End Sub

Private Function CurrPgSec() As String
CurrPgSec = "p" & _
Selection.Information(wdActiveEndAdjustedPageNumber) _
& "s" & _
Selection.Information(wdActiveEndSectionNumber)
End Function

~~~~~~~~~~~

To make the macro print only pages with tables, change the line marked
by <=== to say

Application.Browser.Target = wdBrowseTable

Trying to make the macro print both pages with graphics _and_ pages
with tables in one pass would result in a much more complicated macro,
not something I'd want to post here.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top