B
BruceM
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.
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.