merging multiple subdocuments using vba

S

srfdggy5

hello... I am having a problem merging more than two subdocuments in M
Word. I use the following code below, and the first two document
merge perfectly. However, I will need to merge at least 3 or 4 at
time. IS there a way to do this? Thanks for any help.

If ActiveDocument.Subdocuments.Count > 1 Then
Set aDoc = ActiveDocument
aDoc.Subdocuments.Merge _
aDoc.Subdocuments(1), _
aDoc.Subdocuments(2)
End I
 
W

Word Heretic

G'day srfdggy5 <[email protected]>,

When you merge these first two, they aren't sub dox any more and the
rest 'shuffle down'

Thus, use something like:



Const ToRemove as Long = 4

Dim aDoc as Document
Dim Removed as Long

Set aDoc = ActiveDocument
With aDoc.Subdocuments
While .Count > 0 and removed < ToRemove Then
.Merge .item(1)
Removed=Removed+1
wend
end with

Set aDoc=Nothing


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


srfdggy5 reckoned:
 
S

srfdggy5

Makes total sense... I will give it a try. I sincerely apprecite you
help on this. Such a small problem causes such a huge pain
 
S

srfdggy5

Makes total sense... I will give it a try. I sincerely apprecite you
help on this. Such a small problem causes such a huge pain
 
W

Word Heretic

G'day srfdggy5 <[email protected]>,

No probs - Master Documents are... interesting to say the least :)

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


srfdggy5 reckoned:
 

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