Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Adding watermark to the document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ankesh Mehta - 14 Feb 2006 23:33 GMT
I recorded a macro to insert watermark in a document. The document has
multiple sections and different first page and primary headers.

Word adds the watermark perfectly but when I run the macro the
watermark is not available on many pages and also it is not centered on
the page.

Has anybody else faced this problem too? Any comments will be
appreciated

Thanks,
Charles Kenyon - 15 Feb 2006 00:13 GMT
This is one of many problems with using recorded macros.
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm.

Watermarks are a part of the header/footer structure. Each of you sections
apparently has two headers and footers. You will need to cycle through the
sections and the headers/footers (using ranges, not the selection object)
and insert your watermark in each one.

The following code cycles through storyranges to update fields. It may give
you a start.
Sub FieldsUpdateAllStory()
'   All Story Field Updater
'   Written by Charles Kyle Kenyon 9 December 2004
'   repaired with help from Jezebel 10 December 2004, 28 November 2005
'   Note, if used in protected form this will reset
'       formfields to their defaults
   Dim oStory As Range
   On Error Resume Next
   For Each oStory In ActiveDocument.StoryRanges
       Do
           oStory.Fields.Update
           Set oStory = oStory.NextStoryRange
       Loop Until oStory Is Nothing
   Next
End Sub

The following code inserts a field in the primary header of section 1.

Sub InsertStyleRef()
' Macro written by Charles Kenyon 24 January 2002
' From code posted by David Lett
' Inserts StyleRef field in primary header replacing first paragraph
' - including paragraph mark!
'
   ActiveDocument.Fields.Add _
       Range:=Selection.Sections(1).Headers(wdHeaderFooterPrimary). _
       Range.Paragraphs(1).Range, _
       Type:=wdFieldStyleRef, _
       Text:="witness", _
       PreserveFormatting:=False
End Sub

Hope these are of some help in getting you started. I would suggest
attempting it and then writing back with the code you have if you can't get
it to work.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

>I recorded a macro to insert watermark in a document. The document has
> multiple sections and different first page and primary headers.
[quoted text clipped - 7 lines]
>
> Thanks,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.