The following functions will write values to a named bookmark (here bmTest) already placed in the document, either a building block (autotext) from a named template, or a string value. I have assumed varCType is a string variable. You can call them from your code e.g.
Dim varCType As String
If Not varCType = "Priority 1" Or Not varCType = "Priority 2" Then
BBToBM "bmTest", ThisDocument.AttachedTemplate, "Section7"
Else
FillBM "bmTest, """
End If
You can call the functions as required using different values.
Public Sub BBToBM(strBMName As String, strTemplate As String, strBBName As String)
'Graham Mayor - http://www.gmayor.com
Dim oRng As Range
Dim iLen1 As Integer, iLen2 As Integer
With ActiveDocument
iLen1 = Len(ActiveDocument.Range)
On Error GoTo lbl_Exit
Set oRng = .Bookmarks(strBMName).Range
Application.Templates(strTemplate). _
BuildingBlockEntries(strBBName).Insert _
Where:=oRng, _
RichText:=True
iLen2 = Len(ActiveDocument.Range)
oRng.End = oRng.End + (iLen2 - iLen1)
oRng.Bookmarks.Add strBMName
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
Public Sub FillBM(strBMName As String, strValue As String)
'Graham Mayor - http://www.gmayor.com
Dim oRng As Range
With ActiveDocument
On Error GoTo lbl_Exit
Set oRng = .Bookmarks(strBMName).Range
oRng.Text = strValue
oRng.Bookmarks.Add strBMName
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub