If the code is in the Normal template then it will already be trusted.
What does "when I open a document from the template it doesn't work" mean exactly?
When I run your code:
Code:
Sub ColourTable()
Dim objTable As Table
Dim iRowCounter As Integer
Dim iColumnCounter As Integer
Dim lngBadColor As Long
Dim lngGoodColor As Long
' Predefine colors
lngBadColor = RGB(255, 0, 0)
lngGoodColor = RGB(169, 208, 142)
' Loop through all tables in document
For Each objTable In ActiveDocument.Tables
For iRowCounter = 1 To objTable.Rows.count
For iColumnCounter = 1 To objTable.Columns.count
' Get Table cell
With objTable.Cell(iRowCounter, iColumnCounter)
If InStr(.Range.Text, "TO BE DONE") > 0 Then .Shading.BackgroundPatternColor = lngBadColor
If InStr(.Range.Text, "Yes") > 0 Then .Shading.BackgroundPatternColor = lngGoodColor
If InStr(.Range.Text, "N/A") > 0 Then .Shading.BackgroundPatternColor = lngGoodColor
If InStr(.Range.Text, "None") > 0 Then .Shading.BackgroundPatternColor = lngGoodColor
' If InStr(.Range.Text, "Very good") > 0 Then .Shading.BackgroundPatternColor = lngVeryGoodColor
' If InStr(.Range.Text, "Minor") > 0 Then .Shading.BackgroundPatternColor = lngGoodColor
End With
Next
Next
Next
End Sub
I get