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

Tip: Looking for answers? Try searching our database.

Change watermark via code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
R Fourt - 07 Dec 2007 15:03 GMT
I have seen similar questions that are close to mine, but can't seem to put
it together correctly.

Here's all I want to do. The user clicks a toolbar button and the watermark
toggles between one of two choices.

The watermark is text only. The document has only one section with a header
and footer.

I've played with the code snippets posted in other questions but I don't
quite get the results I want. The macro record doesn't work at all. Arggh
zkid - 08 Dec 2007 01:26 GMT
I agree with this article about why bother?  Anyhow, the same article also
provided the solution to the funky problem with PowerPlus:  
http://www.adras.com/Add-Watermark-macro-Variable-not-defined.t7648-105.html

Here's recorded code that works to insert a picture, then it changes the
picture to a text watermark.  Of course, you need to plug in your picture
path.  The bottom line is that PowerPlus needed to be replared with the mso
language you will read about in the above article.

ActiveDocument.Sections(1).Range.Select
   ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   Selection.HeaderFooter.Shapes.AddPicture(FileName:= _
       "C:\Documents and Settings\Administrator\My Documents\My
Pictures\Glass1.jpg" _
       , LinkToFile:=False, SaveWithDocument:=True).Select
   Selection.ShapeRange.Name = "WordPictureWatermark1"
   Selection.ShapeRange.PictureFormat.Brightness = 0.85
   Selection.ShapeRange.PictureFormat.Contrast = 0.15
   Selection.ShapeRange.LockAspectRatio = True
   Selection.ShapeRange.Height = InchesToPoints(9.19)
   Selection.ShapeRange.Width = InchesToPoints(4.14)
   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
MsgBox "added the picture"
   ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   Selection.HeaderFooter.Shapes("WordPictureWatermark1").Select
   Selection.Delete
   Selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect1, _
       "ASAP", "Times New Roman", 1, False, False, 0, 0).Select
   Selection.ShapeRange.Name = "msoTextEffect1"
   Selection.ShapeRange.TextEffect.NormalizedHeight = False
   Selection.ShapeRange.Line.Visible = False
   Selection.ShapeRange.Fill.Visible = True
   Selection.ShapeRange.Fill.Solid
   Selection.ShapeRange.Fill.ForeColor.RGB = RGB(192, 192, 192)
   Selection.ShapeRange.Fill.Transparency = 0.5
   Selection.ShapeRange.Rotation = 315
   Selection.ShapeRange.LockAspectRatio = True
   Selection.ShapeRange.Height = InchesToPoints(3.05)
   Selection.ShapeRange.Width = InchesToPoints(6.11)
   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
   
   MsgBox "deleted the pic and changed to text"

> I have seen similar questions that are close to mine, but can't seem to put
> it together correctly.
[quoted text clipped - 7 lines]
> I've played with the code snippets posted in other questions but I don't
> quite get the results I want. The macro record doesn't work at all. Arggh
 
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.