A
afswa
I have a routine which assembles various subdocuemtns in to a main container
documet. Each sub-document uses a mailmergs one item deep to update
information in itself before fileds are unlinked, set as a normal document
and then copied and pasted to the container document. It was working OK until
the number of sub documents grew to around the 250 mark. Doug Robbins on the
Mailmerge site suggested a replacement code not using SELECT. But it now
seems that each opened sub-document is not closing and therefore Word falls
over when its maximum document count is reached.
Relevant code section is:
For i = Marks To 1 Step -1
If Left(aMarksArray(i), 2) = "bk" Then
CurName = Right(aMarksArray(i), Len(aMarksArray(i)) - 2)
Set Source = Documents.Open(RawPath + CurName)
ViewType = wdNormalView
Application.Options.Pagination = False
LockFields
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
Set Target = Documents.Open(ThisContainer)
Target.Bookmarks("bk" + CurName).Range.FormattedText =
Source.Range.FormattedText
Set Source = Documents.Close(RawPath +
CurName)(savechanges:=wdDoNotSaveChanges)
End If
Next
Where am I being dense?
documet. Each sub-document uses a mailmergs one item deep to update
information in itself before fileds are unlinked, set as a normal document
and then copied and pasted to the container document. It was working OK until
the number of sub documents grew to around the 250 mark. Doug Robbins on the
Mailmerge site suggested a replacement code not using SELECT. But it now
seems that each opened sub-document is not closing and therefore Word falls
over when its maximum document count is reached.
Relevant code section is:
For i = Marks To 1 Step -1
If Left(aMarksArray(i), 2) = "bk" Then
CurName = Right(aMarksArray(i), Len(aMarksArray(i)) - 2)
Set Source = Documents.Open(RawPath + CurName)
ViewType = wdNormalView
Application.Options.Pagination = False
LockFields
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
Set Target = Documents.Open(ThisContainer)
Target.Bookmarks("bk" + CurName).Range.FormattedText =
Source.Range.FormattedText
Set Source = Documents.Close(RawPath +
CurName)(savechanges:=wdDoNotSaveChanges)
End If
Next
Where am I being dense?