Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Create macro in word 2003 to insert watermark on pages designated as letterhead

Posted on 2008-06-24
2
Medium Priority
?
916 Views
Last Modified: 2012-05-05
I need to create a macro in word 2003 that will insert a background preferably onto all letter headed defined paper. The image when inserted should be positioned behind the text and will cover the entire page like a watermark scaled at 100%: -

Sub MBSBACKGROUND()
'
' MBSlhead Macro
' Insert MBS letter head - Macro recorded 28/01/2008 by luke.griffiths
'
    ActiveDocument.Sections(1).Range.Select
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.HeaderFooter.Shapes.AddPicture(FileName:= _
        "\\*****\MBSLhead.jpg", LinkToFile:=False, _
        SaveWithDocument:=True).Select
    Selection.ShapeRange.Name = "WordPictureWatermark1"
    Selection.ShapeRange.PictureFormat.Brightness = 0.5
    Selection.ShapeRange.PictureFormat.Contrast = 0.5
    Selection.ShapeRange.LockAspectRatio = True
    Selection.ShapeRange.Height = CentimetersToPoints(29.7)
    Selection.ShapeRange.Width = CentimetersToPoints(21)
    Selection.ShapeRange.WrapFormat.AllowOverlap = True
    Selection.ShapeRange.WrapFormat.Side = wdWrapNone
    Selection.ShapeRange.WrapFormat.Type = 3
    Selection.ShapeRange.RelativeHorizontalPosition = _
        wdRelativeVerticalPositionMargin
    Selection.ShapeRange.RelativeVerticalPosition = _
        wdRelativeVerticalPositionMargin
    Selection.ShapeRange.Left = wdShapeCenter
    Selection.ShapeRange.Top = wdShapeCenter
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

It would be perfect if the above could be modified, so instead of appearing on every page of the letter, the watermark would only appears on pages that have been designated letterhead in File/Page Setup/Paper/Paper Source.

Any help would be much appreciated.
0
Comment
Question by:llantwit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
wobbled earned 2000 total points
ID: 21855578
Here you go. - I've slightly modified your code so that it checks each section etc

Sub MBSBACKGROUND()

Dim x As Integer, n As Integer
   
    x = 1
   
    Do While x <= Selection.Information(wdNumberOfPagesInDocument)
       
        Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=x
       
        n = Selection.Information(wdActiveEndSectionNumber)
       
        If Selection.PageSetup.PaperSize = wdPaperLetter Then
            With Selection.ShapeRange
                ActiveDocument.Sections(n).Range.Select
                ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
                Selection.HeaderFooter.Shapes.AddPicture(FileName:= _
                    "\\*****\MBSLhead.jpg", LinkToFile:=False, _
                    SaveWithDocument:=True).Select
                .Name = "WordPictureWatermark1"
                .PictureFormat.Brightness = 0.5
                .PictureFormat.Contrast = 0.5
                .LockAspectRatio = True
                .Height = CentimetersToPoints(29.7)
                .Width = CentimetersToPoints(21)
                .WrapFormat.AllowOverlap = True
                .WrapFormat.Side = wdWrapNone
                .WrapFormat.Type = 3
                .RelativeHorizontalPosition = _
                    wdRelativeVerticalPositionMargin
                .RelativeVerticalPosition = _
                    wdRelativeVerticalPositionMargin
                .Left = wdShapeCenter
                .Top = wdShapeCenter
                ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
            End With

        End If

        x = x + 1

    Loop
 
end sub
0
 

Author Comment

by:llantwit
ID: 21856471
Could the macro be changed so that instead of selecting (wdPaperLetter): -

If Selection.PageSetup.PaperSize = wdPaperLetter Then

It will select the pages that are printing from tray 3, which contains the headed paper.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question