Subdocument Merge Loop (MS Word)

S

srfdggy5

Question: I ammerging multiple subdocuments in Word, and I continuall
get a "Bad Parameter" error when I use the last subdocument to merge.
Example: I have 4 subdocuments, and I merge the first 3... No problem
However, If I merge, lets say, all 4, or even subdocuments 1,2, and 4
I get a bad parameter error after the lst subdocument loads. Help?
Thanks in advance...

My code is below, with the merge loop at the bottom...

Private Sub CommandButton1_Click()
Sheet = 0
If CheckBox1 = True Then Sheet = Sheet + 1
If CheckBox1 = True Then
ActiveDocument.ActiveWindow.View.Type = wdMasterView
ActiveDocument.Subdocuments.AddFromFile _
Name:="F:\ITS\TestArea\Page 1"
End If
If CheckBox2 = True Then Sheet = Sheet + 1
If CheckBox2 = True Then
ActiveDocument.ActiveWindow.View.Type = wdMasterView
ActiveDocument.Subdocuments.AddFromFile _
Name:="F:\ITS\TestArea\Page 2"
End If
If CheckBox3 = True Then Sheet = Sheet + 1
If CheckBox3 = True Then
ActiveDocument.ActiveWindow.View.Type = wdMasterView
ActiveDocument.Subdocuments.AddFromFile _
Name:="F:\ITS\TestArea\Page 3"
End If
If CheckBox4 = True Then Sheet = Sheet + 1
If CheckBox4 = True Then
ActiveDocument.ActiveWindow.View.Type = wdMasterView
ActiveDocument.Subdocuments.AddFromFile _
Name:="F:\ITS\TestArea\Page 4"


Dim aDoc As Document

Set aDoc = ActiveDocument
With aDoc.Subdocuments
While .Count < Sheet + 1
.Merge .Item(1)
Wend
End Wit
 

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