B
BruceM
Thanks to this group I have code to print the part of a document located
between two bookmarks:
Set r = ActiveDocument.Range( _
Start:=ActiveDocument.Bookmarks("DocStart").End, _
End:=ActiveDocument.Bookmarks("DocEnd").Start)
r.Select
ActiveDocument.PrintOut Range:=wdPrintSelection
Set r = Nothing
Selection.HomeKey unit:=wdStory
I have placed this code into an add-in, and I use an autoexec macro to add a
custom toolbar with a button for running the macro. It works as it should
(although I wish I could get it to print the header and footer, but that may
not be possible, from what I can understand).
However, the main reason for this post is that I would like to add a
watermark to the range of pages being printed. This is some code (abridged
for readability) I created using the macro recorder (except that I changed
"PowerPlusWaterMarkObject1" to "msoTextEffect1").
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect1, _
"XYZ Company", "Arial Black", 1, False, False, 0, 0).Select
Selection.ShapeRange.Name = "msoTextEffect1"
Selection.ShapeRange.TextEffect.NormalizedHeight = False
' More Selection.ShapeRange items
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
I can run the macro in the document in which it was created, but I cannot
find the trick to having the macro run in the document containing the
bookmarks. In other words, I open a document, and the Add-In loads with the
code to print between the bookmarks. I can run the macro, and it prints
only the part of the document it should. However, I cannot get it to run
the watermark code on the open document. I expect part of the problem is
that Sections(1) does not apply, and things of that sort, but I can't seem
to sort it all out. Can I run the watermark code along with the code to
print the selection between the bookmarks?
between two bookmarks:
Set r = ActiveDocument.Range( _
Start:=ActiveDocument.Bookmarks("DocStart").End, _
End:=ActiveDocument.Bookmarks("DocEnd").Start)
r.Select
ActiveDocument.PrintOut Range:=wdPrintSelection
Set r = Nothing
Selection.HomeKey unit:=wdStory
I have placed this code into an add-in, and I use an autoexec macro to add a
custom toolbar with a button for running the macro. It works as it should
(although I wish I could get it to print the header and footer, but that may
not be possible, from what I can understand).
However, the main reason for this post is that I would like to add a
watermark to the range of pages being printed. This is some code (abridged
for readability) I created using the macro recorder (except that I changed
"PowerPlusWaterMarkObject1" to "msoTextEffect1").
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect1, _
"XYZ Company", "Arial Black", 1, False, False, 0, 0).Select
Selection.ShapeRange.Name = "msoTextEffect1"
Selection.ShapeRange.TextEffect.NormalizedHeight = False
' More Selection.ShapeRange items
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
I can run the macro in the document in which it was created, but I cannot
find the trick to having the macro run in the document containing the
bookmarks. In other words, I open a document, and the Add-In loads with the
code to print between the bookmarks. I can run the macro, and it prints
only the part of the document it should. However, I cannot get it to run
the watermark code on the open document. I expect part of the problem is
that Sections(1) does not apply, and things of that sort, but I can't seem
to sort it all out. Can I run the watermark code along with the code to
print the selection between the bookmarks?