Re: Autotext watermarks in multi-section documents

From: Chris J (cjarman_at_paynehicksbeach.co.uk)
Date: 10/27/04


Date: 27 Oct 2004 05:21:30 -0700

OK, here is the relevant section "verbatim". I fear imposed line
length limit on postings will cause some lines to wrap around but I
trust this will be obvious and won't cause confusion. A few
explanations follow below the code

For R = SecStart To SecEnd
    Selection.GoTo wdGoToSection, R 'ensure all sections get
Watermark
    With ActiveDocument.Sections(R)
      'insert watermark in first page header of section, if different
from primary section header
        If .PageSetup.DifferentFirstPageHeaderFooter = True Then
          'don't insert if header is same as previous section and
already inserted there
          If R = SecStart _
              Or .Headers(wdHeaderFooterFirstPage).LinkToPrevious =
False Then
            If LetterDoc = False And BillDoc = False Then
          'don't insert watermark in first page header of section 2 of
letters or bills
          'continuous section break on first page: superimposition
results
              ActiveWindow.ActivePane.View.SeekView =
wdSeekFirstPageHeader
              Templates(PHBM).AutoTextEntries(ReqdAT) _
                  .Insert Where:=Selection.Range, RichText:=True
            End If
          End If
        End If
          
        'insert watermark in primary section header, if not same as
previous where already inserted
        If R = SecStart _
            Or .Headers(wdHeaderFooterPrimary).LinkToPrevious = False
Then
          ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryHeader
          Templates(PHBM).AutoTextEntries(ReqdAT) _
              .Insert Where:=Selection.Range, RichText:=True
          If LetterDoc = True Or (BillDoc = True And ReqdAT =
"WMDraft") Then
              If Selection.Information(wdNumberOfPagesInDocument) > 1
Then
                  Selection.GoTo What:=wdGoToPage, Which:=2
                  Templates(PHBM).AutoTextEntries(ReqdAT) _
                      .Insert Where:=Selection.Range, RichText:=True
                  Selection.GoTo What:=wdGoToSection, Which:=R
              End If
          End If
        End If
          
        'return to main document
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    End With
Next R

Explanations: SecStart and SecEnd are the sections (varying according
to the custom template from which the document was prepared) from and
to which (inclusive) the watermark is to be inserted. LetterDoc and
BillDoc are, as you'll guess from the comment, boolean variables which
indicate particular custom templates. Other variables are probably
obvious.

Thanks for the interesting code - I'll defer trying anything based on
this pending further postings on this thread, but one comment at this
stage: where there is a continuous section break so that the page
where it appears is (in part) in each of two or more sections, there
would seem to be a risk that inserting the watermark into every header
in the document could lead to superimposition as I have experienced
already - so I'd possibly need to modify it anyway for that reason.
Do you agree? If you can see where my existing code goes wrong I
think I'd prefer to stick with that basic approach, suitably modified,
if it's not overly cumbersome.

Chris J

"Jezebel" <dwarves@heaven.com.kr> wrote in message news:<u7OmQn6uEHA.3276@TK2MSFTNGP15.phx.gbl>...
> Might be better if you posted the code: it sounds like a bug in the way you
> are 'going to' the various headers.
>
> This code iterates all the headers actually defined in your document --
>
> Dim pRange as Word.Range
> Dim pIndex as long
>
> For pIndex = 1 to 3
> Set pRange = ActiveDocument.StoryRanges(Choose(pIndex,
> wdFirstPageHeaderStory, wdEvenPagesHeaderStory, wdOddPagesHeaderStory))
> Do until pRange is nothing
> ... add the watermark to pRange
> set pRange = pRange.NextStoryRange
> Loop
> Next
>
>
>
>
>
> "Chris J" <cjarman@paynehicksbeach.co.uk> wrote in message
> news:d21d3c84.0410261024.493b7323@posting.google.com...
> > I am having difficulty with automated insertion of watermarks (eg
> > diagonal DRAFT) from Autotext. The theory seems to be that, by
> > inserting these in the header, each page of the document will be
> > watermarked. But this is not working in practice - I either get the
> > watermark on only some of the pages, or twice on one page
> > (superimposed) and not elsewhere.
> >
> > A typical document where the problem arises is laid out as follows:
> > - Section break between sections 1 and 2 is on page 1 and continuous
> > (section 1 first page header contains a letterheading), section 1
> > primary header not visible because section 1 ends on page 1)
> > - Section 2 primary header is linked to previous (though behaviour
> > seems unchanged if I unlink it instead); section 2 doesn't have a
> > separate first page header, but if it did then presumably this too
> > would not be visible because first page of section 2 also contains
> > section 1. Section 2 continues to end of document (assume a 4-page
> > letter).
> >
> > The essence of the code I am using (in English rather than VBA) says:
> > - go to section 2
> > - if there's a different first page header, go to the first page
> > header of section 2 and insert the autotext (but this is set to be
> > skipped for a document configured as described above)
> > - go to the primary header (here still in section 2) and insert the
> > autotext
> >
> > If I leave it at that, I get the watermark only on page 1. (If I
> > don't set it to skip the stage mentioned, I get the watermark imposed
> > twice on page 1, and still not elsewhere.)
> >
> > So I added further lines to say go to page 2 (still with section 2
> > primary header open) and insert the autotext. That gets the autotext
> > onto page 2 but not pages 3 and 4. If I extend the code to say repeat
> > for pages 3 and 4 (which should be irrelevant because they are in
> > section 2 just as page 2 is), the cursor returns (at the Go To line)
> > to a frame on page 1 (anchored in section 1), and the
> > autotext/watermark is then superimposed on the page 1 watermark
> > (actually rather untidily - one impression is not an exact
> > superimposition). Nothing happens on page 3 or page 4.
> >
> > Can anyone explain what's going wrong here please? I could post the
> > extract of code if needed but I thought it would be easier to explain
> > as above in the first place.
> >
> > Thanks
> >
> > Chris J



Relevant Pages

  • Re: Autotext watermarks in multi-section documents
    ... > There's no problem about superimpostion simply by inserting the watermark in ... > every header: only one header gets shown on the page, ... >> BillDoc are, as you'll guess from the comment, boolean variables which ... >> would seem to be a risk that inserting the watermark into every header ...
    (microsoft.public.word.formatting.longdocs)
  • Re: Autotext watermarks in multi-section documents
    ... There's no problem about superimpostion simply by inserting the watermark in ... every header: only one header gets shown on the page, ... > would seem to be a risk that inserting the watermark into every header ...
    (microsoft.public.word.formatting.longdocs)
  • Autotext watermarks in multi-section documents
    ... diagonal DRAFT) from Autotext. ... (section 1 first page header contains a letterheading), ... Section 2 primary header is linked to previous (though behaviour ... If I leave it at that, I get the watermark only on page 1. ...
    (microsoft.public.word.formatting.longdocs)
  • Re: Watermarks
    ... If the watermark is not to appear only on the first page then a different ... watermark - open the header view and save the image as an autotext entry. ... Now in the header insert a conditional field, ...
    (microsoft.public.word.docmanagement)
  • Re: Cannot run FormatBackgroundWatermark or find dialog
    ... You programmatically set a watermark by inserting a shape into the ... Steve Hudson - Word Heretic ... >table in header]. ...
    (microsoft.public.word.vba.general)