Here is the Code - unable to locate an issue
Here is the code. Note that I was unsuccessful in finding a line of code with an issue after adding a breakpoint at the Documents.Add. I am sure the code could be written better but the Code has worked for over a year until today. I really appreciate the reply!
Private Sub cmdMemo_Click()
On Error Resume Next
Documents.Add "path to form/word template"
Dim oDoc As Document
For Each oDoc In Documents
oDoc.Activate
Set oVars = ActiveDocument.Variables
Call FillVariables
Call FillVariables2
If Me.cboNochildren.Value = "0" Then Noofchild0
If Me.cboNochildren.Value = "1" Then Noofchild1
If Me.cboNochildren.Value = "2" Then Noofchild2
If Me.cboNochildren.Value = "3" Then Noofchild3
If Me.cboNochildren.Value = "4" Then Noofchild4
ActiveDocument.Fields.Update
If ActiveDocument.AttachedTemplate.Name <> "Data Set.DOTM" Then ActiveDocument.Fields.Unlink
Dim rngStory As Word.Range
Dim oShape As Word.Shape
For Each rngStory In ActiveDocument.StoryRanges
If rngStory.ShapeRange.Count > 0 Then
For Each oShape In rngStory.ShapeRange
If oShape.TextFrame.HasText Then
oShape.TextFrame.TextRange.Fields.Update
oShape.TextFrame.TextRange.Fields.Unlink
End If
Next oShape
End If
Set rngStory = rngStory.NextStoryRange
Next rngStory
ActiveDocument.Content.NoProofing = False
Next oDoc
Set oVars = Nothing
Me.Hide
End Sub
|