' strN is the block of code we desire to add (in a string variable)
' Delete any prior code in this module StandingCodeLines = ActiveDocument.VBProject.VBComponents("ThisDocument").CodeModule.CountOfLines
If StandingCodeLines > 0 Then
ActiveDocument.VBProject.VBComponents("ThisDocument").CodeModule.DeleteLines 1, StandingCodeLines
End If
' Add the module to "This Document" ActiveDocument.VBProject.VBComponents("ThisDocument").CodeModule.AddFromString strN