View Single Post
 
Old 09-24-2018, 06:46 AM
shu shu is offline Windows 10 Office 2016
Novice
 
Join Date: Jun 2018
Posts: 6
shu is on a distinguished road
Default Inserting watermarks in a doc with several sections

Helloo,

I tried to insert watermarks in the middle of every page in a document with several sections and it worked (Code is below). But when there's a table in the header then the watermark gets not placed in the middle of the page but elsewhere. Does anyone know why?

Thx and BR,
shu

Code:
Dim wassZ1 As Shape
Dim i As Long

For i = 1 To ActiveDocument.Sections.Count
    
    With ActiveDocument.Sections(i).Headers(wdHeaderFooterPrimary).Range
            'Überprüfen ob schon ein WZ vorhanden ist, wenn ja dann löschen
            If .ShapeRange.Count > 0 Then
                .ShapeRange(1).Delete
            End If
     End With
        
        'neues Wasserzeichen einfügen
       With ActiveDocument.Sections(i)
             Set wassZ1 = .Headers(wdHeaderFooterPrimary).Shapes.AddTextEffect(PresetTextEffect:=msoTextEffect2, _
             Text:="DRAFT1", FontName:="Arial", FontSize:=36, FontBold:=msoTrue, FontItalic:=msoFalse, _
             Left:=1, Top:=1)
       End With
    

    With wassZ1
    .Fill.Visible = msoTrue
    .Fill.Solid
    .Fill.ForeColor.RGB = RGB(192, 192, 192)
    .Fill.Transparency = 0.5
    .Line.Weight = 0.75
    .Line.DashStyle = msoLineSolid
    .Line.Style = msoLineSingle
    .Line.Transparency = 0
    .Line.Visible = msoFalse
    .LockAspectRatio = msoFalse
    .Rotation = 330
    .Height = CentimetersToPoints(8)
    .Width = CentimetersToPoints(15)
    .RelativeHorizontalPosition = _
        wdRelativeHorizontalPositionMargin
    .RelativeVerticalPosition = _
        wdRelativeVerticalPositionMargin
    .RelativeHorizontalSize = wdRelativeHorizontalSizePage
    .RelativeVerticalSize = wdRelativeVerticalSizePage
    .Left = wdShapeCenter
    .LeftRelative = wdShapePositionRelativeNone
    .Top = wdShapeCenter
    .TopRelative = wdShapePositionRelativeNone
    .WidthRelative = wdShapeSizeReativeNone
    .HeightRelative = wdShapeSizeRelativeNone
    'Vali docs
    '.IncrementLeft 120
    '.IncrementTop 280
   End With
           
    Next I

Last edited by macropod; 09-24-2018 at 05:07 PM. Reason: Added code tags
Reply With Quote