The following method re-purposes a built-in building block to add the data in the first page header:
To remove itSub InsertDateWatermark() Dim oRng As Range Dim oHeader As HeaderFooter Dim oTemplate As Template ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True Set oHeader = ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage) Set oRng = oHeader.Range On Error Resume Next For Each oTemplate In Application.Templates If oTemplate.name Like "Built-In Building Blocks*" Then oTemplate.BuildingBlockEntries("CONFIDENTIAL 1").Insert Where:=oRng, _ RichText:=True End If Next oTemplate With oRng.ShapeRange.Item(1) .TextEffect.Text = Format(Date, "Short Date") .TextEffect.FontSize = 24 .Height = 29.25 .Width = 102# End With lbl_Exit: Exit Sub End Sub
Sub RemoveDateWatermark() Dim oRng As Range Dim oHeader As HeaderFooter On Error Resume Next ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True Set oHeader = ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage) Set oRng = oHeader.Range oRng.ShapeRange.Item(1).Delete lbl_Exit: Exit Sub End Sub




Reply With Quote