From: G. Harland on 7 Mar 2007 20:48 I have a Word document with nine sections. None of the sections are linked because there is specific text in each header. From an Access database, I have code that opens the Word document, replaces a bunch of bookmarks, updates some fields and the table of contents, saves the document, and exits. Now, I have to add a watermark. After spending way too much time coming up with a solution, it turns out that the code only writes the watermark in the first section. So I am looking for any help, advice, tips, code samples, or anything else you can think of that will help me out (and take pity on me, as I am a PowerBuilder developer by trade, acting as a VB/VBA developer as a favor to my boss). Thanks, Glenn Harland Here's the code: wmtext = IIf(IsNull(watermark_text.Value), "", watermark_text.Value) For ctr = 1 To oTemp.Sections.Count For idx = 1 To 3 With oTemp.Sections(ctr).Headers(idx).Shapes.AddTextEffect(powerpluswatermarkobject1, wmtext, "Times New Roman", 1, False, False, 0, 0) .TextEffect.NormalizedHeight = False .Line.Visible = False .Fill.Visible = True .Fill.Solid .Fill.ForeColor.RGB = RGB(192, 192, 192) .Fill.Transparency = 0.5 .Rotation = 315 .LockAspectRatio = True .Height = oWord.InchesToPoints(2.27) .Width = oWord.InchesToPoints(7.95) .WrapFormat.AllowOverlap = True .WrapFormat.Side = wdWrapNone .WrapFormat.Type = 3 .RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin .RelativeVerticalPosition = wdRelativeVerticalPositionMargin .Left = wdShapeCenter .Top = wdShapeCenter End With Next Next
From: Shauna Kelly on 7 Mar 2007 21:59 Hi Glenn My sympathies: I've played with this problem on and off since Word 2000 days. I find that sometimes the watermark just is not inserted; and other times Word inserts 2 watermarks in one section and none in another. The first page header in Section 2 seems to be a particular place that Word doesn't like. My current suggestions are more voodoo than programming, but they sometimes work: - move the cursor to the end of the document before you begin - repaginate before you begin (oDoc.Repaginate) - contrary to the general advice about avoiding moving the selection, select the range of the header or footer before you insert the shape (eg oTemp.Sections(ctr).Headers(idx).range.select). There is no earthly reason why that is necessary. Except that if it isn't there, Word sometimes puts all the watermarks in the Odd header for Section 1, regardless of what you tell it. You'll need to .Select something more pleasant for the user at the end of your routine. - use msoTextEffect2 rather than powerpluswatermarkobject1 - get a reference to the shape when you insert it (eg set shpWatermark = oTemp.Sections(ctr).Headers(idx).Shapes.AddTextEffect....) - then use that shpWatermark to set as many of the properties as you can (eg position, colour etc) *after* the shape is actually inserted If none of that works, then try updating all fields and repaginating after you insert each watermark. This slows down a big document considerably, but that might be preferable to having watermarks in the wrong places. Hope this helps. Shauna Kelly. Microsoft MVP. http://www.shaunakelly.com/word "G. Harland" <glenn(_no_spam_)harland(a)hotmail.com> wrote in message news:60B37530-62D0-4882-A5A5-904A7C2C43C9(a)microsoft.com... >I have a Word document with nine sections. None of the sections are linked > because there is specific text in each header. > > From an Access database, I have code that opens the Word document, > replaces > a bunch of bookmarks, updates some fields and the table of contents, saves > the document, and exits. > > Now, I have to add a watermark. After spending way too much time coming > up > with a solution, it turns out that the code only writes the watermark in > the > first section. So I am looking for any help, advice, tips, code samples, > or > anything else you can think of that will help me out (and take pity on me, > as > I am a PowerBuilder developer by trade, acting as a VB/VBA developer as a > favor to my boss). > > Thanks, > Glenn Harland > > Here's the code: > wmtext = IIf(IsNull(watermark_text.Value), "", watermark_text.Value) > For ctr = 1 To oTemp.Sections.Count > For idx = 1 To 3 > With > oTemp.Sections(ctr).Headers(idx).Shapes.AddTextEffect(powerpluswatermarkobject1, > wmtext, "Times New Roman", 1, False, False, 0, 0) > .TextEffect.NormalizedHeight = False > .Line.Visible = False > .Fill.Visible = True > .Fill.Solid > .Fill.ForeColor.RGB = RGB(192, 192, 192) > .Fill.Transparency = 0.5 > .Rotation = 315 > .LockAspectRatio = True > .Height = oWord.InchesToPoints(2.27) > .Width = oWord.InchesToPoints(7.95) > .WrapFormat.AllowOverlap = True > .WrapFormat.Side = wdWrapNone > .WrapFormat.Type = 3 > .RelativeHorizontalPosition = > wdRelativeHorizontalPositionMargin > .RelativeVerticalPosition = wdRelativeVerticalPositionMargin > .Left = wdShapeCenter > .Top = wdShapeCenter > End With > Next > Next >
|
Pages: 1 Prev: Extract RTF text from word without clipborad function????? Next: Debug Clear |