List pages to print, select one page



I have a situation where the user may select one of several possible pages
to print. My idea (which may be off the mark, but it's what has occurred to
me) is that each of the pages would contain a bookmark. I have adapted some
code Jay Freedman posted about a year ago to list bookmarks. I run the code
as a macro.

Dim bkm As Word.Bookmark
Dim doc As Word.Document
Dim strBkm As String
Set doc = ActiveDocument
strBkm = ""

For Each bkm In doc.Bookmarks
strBkm = strBkm & bkm.Name & vbCrLf
Next

MsgBox strBkm

This produces a list of bookmarks in the document. I realize the list as
produced by this code is for display only, but what I hope is that the user
can select from the list, thereby printing the page on which the bookmark
appears. I already have worked out some code that can identify the page
number. Maybe it would be something like:

Dim b1 as Long

b1 = ActiveDocument.Bookmarks("MoreStart").Range _
.Information(wdActiveEndAdjustedPageNumber)
ActiveDocument.PrintOut _
Range:=wdPrintFromTo, From:=CStr(b1), To:=CStr(b1)

This may not be the smoothest way to accomplish what I need. For instance,
maybe I can produce a list of bookmarks, and when the user selects one Word
can go to that page, and I can use wdPrintSelection, or something like that.
Or maybe there is another option I have not considered.

The main thing is that I would first need to have a user-selectable list to
identify the page that needs to be printed.


.



Relevant Pages

  • Re: Best way to use a flexible word table with printmerge
    ... I realized that the bookmarks are removed with the mail merge. ... Dim doc as Word.Document ... Dim tbl as Word.Table ...
    (microsoft.public.word.docmanagement)
  • Re: List pages to print, select one page
    ... and to populate the list box with selected bookmarks. ... Dim oBMs As Bookmarks ... Dim strBkm As String ...
    (microsoft.public.word.vba.general)
  • Re: bookmarks
    ... ' Bookmarks Macro ... Dim bkm As Word.Bookmark ... Dim doc As Word.Document ...
    (microsoft.public.word.docmanagement)
  • Re: bookmarks
    ... the names in an array before deleting the bookmarks. ... Dim bkm As Word.Bookmark ... Dim doc As Word.Document ...
    (microsoft.public.word.docmanagement)
  • Re: Copy numbers from Excel to Word with VBA
    ... The first one's got a bug in getting the Excel file. ... it works to populate Word bookmarks from an Excel file. ... Dim objDoc As Document ... Dim strBkm As String ...
    (microsoft.public.word.vba.general)

Loading