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 / October 2007

Tip: Looking for answers? Try searching our database.

Word 2007 Watermark Automation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jharris@datamationtech.com - 25 Oct 2007 21:31 GMT
I have some vba code in Word 2003 to automatically add a watermark to
a document through a macro button.
I have adjusted it to work with Word 2007, but it adds a header space
to the top of each page.
If I manually add the watermark it does not create the header space at
the top, only when I add the watermark via the macro.

Here is the code:

   ActiveDocument.Sections(1).Range.Select
   ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   Selection.HeaderFooter.Shapes.AddPicture(FileName:= _
       "C:\MS logo\em new logo2.png", LinkToFile:=False,
SaveWithDocument:=True) _
       .Select
   Selection.ShapeRange.Name = "WordPictureWatermark6034789"
   Selection.ShapeRange.PictureFormat.Brightness = 0.5
   Selection.ShapeRange.PictureFormat.Contrast = 0.5
   Selection.ShapeRange.LockAspectRatio = True
   Selection.ShapeRange.Height = InchesToPoints(0.59)
   Selection.ShapeRange.Width = InchesToPoints(1.1)
   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 = 455
   Selection.ShapeRange.Top = 5
   ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
   Selection.HomeKey Unit:=wdStory
       ActiveDocument.Protect Password:="mslegal", NoReset:=False,
Type:= _
       wdAllowOnlyFormFields
Doug Robbins - Word MVP - 26 Oct 2007 05:16 GMT
The following code should overcome the problem (caused by selecting the
header range) and will probably also execute in less time.

With Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range
   .InlineShapes.AddPicture "C:\MS logo\em new logo2.png", _
   LinkToFile:=False, SaveWithDocument:=True
   With .ShapeRange(1)
       .PictureFormat.Brightness = 0.5
       .PictureFormat.Contrast = 0.5
       .LockAspectRatio = True
       .Height = InchesToPoints(0.59)
       .Width = InchesToPoints(1.1)
       .WrapFormat.AllowOverlap = True
       .WrapFormat.Side = wdWrapNone
       .WrapFormat.Type = 3
       .RelativeHorizontalPosition = _
       wdRelativeVerticalPositionMargin
       .RelativeVerticalPosition = _
       wdRelativeVerticalPositionMargin
       .Left = 455
       .Top = 5
   End With
End With

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I have some vba code in Word 2003 to automatically add a watermark to
> a document through a macro button.
[quoted text clipped - 31 lines]
> Type:= _
>        wdAllowOnlyFormFields

Rate this thread:






 
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.