I’ve been playing with Quick Parts and loving being able to create a Quick Parts building block that I assigned either to a footer or a watermark gallery.
I’ve been using the Building Blocks Organiser to insert quick parts, and love it. When I select a building block that is assigned to the footer gallery it automatically opens the footer and inserts it and all I have to do is close the footer.
When I select a building block that is assigned to the watermark gallery it puts the watemark in the header.
However, when I then use VBA to insert the quick part I get different results:
The footer quick part gets added to the header.
The watermark quick part doesn’t get added to the header, it just appears on the current page of the document, behind text.
This is the code I’m using. I really hope someone can point out where I’m going wrong. This code works beautifully for standard autotext entries that just have to appear at the insertion point, and who have been assigned to the autotext gallery.
Public strAutotext As String Sub InsertLAAutotext() Dim strMasterTemplate As Template Dim colAutoText As AutoTextEntries Dim objAutoText As AutoTextEntry ‘Dim arrEntries As Variant Dim i As Integer Templates.LoadBuildingBlocks i = 1 For Each atemp In Templates If atemp = “Legal Assist Building Blocks.dotx” Then Set strMasterTemplate = Templates(i) i = i + 1 Next atemp ReDim arrEntries(0) Set colAutoText = strMasterTemplate.AutoTextEntries For Each objAutoText In colAutoText Bound = UBound(arrEntries) If arrEntries(Bound) = “” Then arrEntries(Bound) = objAutoText.Name Else ReDim Preserve arrEntries(Bound + 1) arrEntries(Bound + 1) = objAutoText.Name End If Next objAutoText strMasterTemplate.BuildingBlockEntries(strAutotext). _ Insert Where:=Selection.Range, RichText:=True End Sub Sub WatermarkFileCopy() strAutotext = “FileCopy” Call InsertLAAutotext End Sub Sub WatermarkConfidential() strAutotext = “Confidential” Call InsertLAAutotext End Sub Sub WatermarkDraft() strAutotext = “Draft” Call InsertLAAutotext End Sub Sub RemoveWatermark() Application.ScreenUpdating = False Dim RngSel As Range, Scn As Section, HdFt As HeaderFooter, iView As Long With ActiveDocument Set RngSel = Selection.Range iView = ActiveWindow.View.Type For Each Scn In .Sections For Each HdFt In Scn.Headers HdFt.Range.Select WordBasic.RemoveWatermark Next ‘ For Each HdFt In Scn.Footers ‘ HdFt.Range.Select ‘ WordBasic.RemoveWatermark ‘ Next Next End With RngSel.Select ActiveWindow.View.Type = iView Set RngSel = Nothing Application.ScreenUpdating = True End Sub