Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I automate a watermark in Word

Status
Not open for further replies.

FoxEgg

Programmer
Mar 24, 2002
749
AU
I am trying to make some documents more secure by putting a large Watermark on the page... which is coded specifically for the individual. (Table is INVESTOR and the Field is Investor.Code)

I want to use a really big font (say 100), and about 25% opacity (ie faded text) and I want to centre it on the page and landscape format.

I have done a quick search on Watermark Automation with not much joy.

Any clues much appreciated

John Fox
 
Start looking at
Selection.HeaderFooter.Shapes.AddTextEffect
part of the word object. I saw code on vba express forum using this to insert watermarks.
 
John Fox.

Start word, go to Tools->Macro, and start recording a macro. Then go to Format->BackGround->Printed Wartermark, and select Picture watermark and specify your picture. Stop the macro recording, go the edit you macro, and you see how it is done, the code is "almost VFP".



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks guys..

Mike,

I wanted to put a Watermark on the page... which is a text field coded specifically for the individual. (Table is INVESTOR and the Field is Investor.Code)

I believe that the Watermark only allows me to add a .jpg ...so I presume that I have to save the investor.code field as a .jpg ?

JF
 
I believe that the Watermark only allows me to add a .jpg ...so I presume that I have to save the investor.code field as a .jpg ?

At least in Word 2003, when you select format->background->printed watermark, you have the option to select a text watermark. However, I was unable to easily convert the recored macro to VFP code, so you will probably be better off to save the field in some graphics format and use code like this:

Code:
oWord = CREATEOBJECT("Word.Application")
oWord.documents.add()

oWord.Visible=.t.
oWord.ActiveDocument.Shapes.AddPicture("FullPath2MyGraphicsFile")

WITH  oWord.ActiveDocument.Shapes(1)
  .ZOrder( 5 )
  WITH .Fill
    .Visible = .t.
    .Transparency = 0.2
  ENDWITH
  WITH .Line
    .Weight = 4
    .Transparency = 0.4
    .Visible = .t.
  ENDWITH
  WITH .PictureFormat
    .Brightness = 0.85
    .Contrast = 0.15
  ENDWITH
  .LockAspectRatio = .t.
  .Height = 64.1*5
  .Width = 64.1*5
ENDWITH


Marcia G. Akins
 
There is vba code that inserts text watermarks from a click event of a vba form at

Another approach that I have use to identify documents and changes is placing a bookmark in the footer, building a string at print or save time and printing it onto the document then.
Code:
* Stamp the footer with last edit
*build string for stamp
cstamp=TTOC(DATETIME())
*!** place stamp in footer of document
loDoc.bookmarks("footer").range.text=[Last Edit was ]+cstamp + CHR(13)
 
Hi John,

I've created text watermarks in Word (2000 and above) quite easily. I haven't tried to automate it, but if you try these steps in Word itself, you might be able to record it as a macro.

1. Go into Headers & Footers. In the header, insert a text box.

2. Extend the text box downward so that it fills the page.

3. Click on the border of the text box. Right-click and select Format Textbox.

4. On the layout tab, choose Behind Text.

5. Inside the textbox, type the text. Format it with a pale colour. Optionally, use the Rotate Text option (Format menu) to set it vertically (or diagonally if your version of Word allows that).

From now on, the watermark will appear behind every page in the document.

Rather than repeating all those steps programmatically, it might be easier to put the watermark in a template, and to use that template as the base for your new documents. Then you only need to programmatically alter the text in the textbox, which should be easy.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top