Macros disappearing

S

SCook

I have a template that contains several macros. (see below) However, from
time to time, for no apparent reason, the macros dissapear and I am left with
a template that does not function. I have tried saving it as a template, I
have tried saving it as a Word Doc, neither seems to make a difference. I do
not know whether this is related or not, but I am also periodically (when
opening the template) receiveing some sort of message that asks if I want to
save the changes made to the Normal.dot.

Any advise would be appreciated!
S.Cook

MACROS:
ADD A NEW LINE

Sub addanewline()
'
' addanewline Macro
' Macro created 6/29/2005 by SDG Document Services LLC
'
' To add a new row to a table containing formfields in every column

' automatically on exit from the last cell in the present last row of the
table

Dim rownum As Integer, i As Integer

ActiveDocument.Unprotect

Selection.Tables(1).Rows.Add

rownum = Selection.Tables(1).Rows.Count

For i = 1 To Selection.Tables(1).Columns.Count

ActiveDocument.FormFields.Add Range:=Selection.Tables(1).Cell(rownum,
i).Range, Type:=wdFieldFormTextInput

Next i

Selection.Tables(1).Cell(Selection.Tables(1).Rows.Count,
Selection.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro =
"addanewline"

Selection.Tables(1).Cell(Selection.Tables(1).Rows.Count,
1).Range.FormFields(1).Select

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

****

HIGHLIGHT WHEN CHECKED – GREEN

Sub highlightwhencheckedGREEN()
'
' highlightwhencheckedGREEN Macro
' Macro created 6/22/2005 by SDG Document Services LLC
'
Dim ffname As String
ffname = Selection.FormFields(1).Name
With ActiveDocument
.Unprotect
If .FormFields(ffname).CheckBox.Value = True Then
.Bookmarks(ffname).Range.Rows(1).Shading.BackgroundPatternColor _
= wdColorGreen
Else
.Bookmarks(ffname).Range.Rows(1).Shading.BackgroundPatternColor _
= wdColorAutomatic
End If
.Protect wdAllowOnlyFormFields, NoReset
End With

End Sub

****

HIGHLIGHT WHEN CHECKED – YELLOW

Sub highlightwhencheckedYELLOW()
'
' highlightwhencheckedYELLOW Macro
' Macro created 6/22/2005 by SDG Document Services LLC
'
Dim ffname As String
ffname = Selection.FormFields(1).Name
With ActiveDocument
.Unprotect
If .FormFields(ffname).CheckBox.Value = True Then
.Bookmarks(ffname).Range.Rows(1).Shading.BackgroundPatternColor _
= wdColorYellow
Else
.Bookmarks(ffname).Range.Rows(1).Shading.BackgroundPatternColor _
= wdColorAutomatic
End If
.Protect wdAllowOnlyFormFields, NoReset
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top