DavG63
12-15-2015, 01:30 PM
Hi
I have a Word document broken down into three sections, each section containing the same basic document but with different DocVariables so that I can create up to three copies at a time, using different base information, i.e. name and address details for three different people.
In my current code ComboBox1 relates to Section 1; ComboBox 2 to Section 2; and ComboBox3 to Section 3. There will always be at least one version of my document created when running the macro and so I've focused on variables involving ComboBoxes 2 and 3.
IF Me.ComboBox2.Value = "" and Me.ComboBox3.Value = "" Then
ActiveDocument.Sections(3).Range.Delete
ActiveDocument.Sections(2).Range.Delete
Selection.WholeStory
Selection.Fields.Unlink
Else
End If
If Me.ComboBox2.Value <> "" and Me.ComboBox3.Value = "" Then
ActiveDocument.Sections(3).Range.Delete
Selection.WholeStory
Selection.Fields.Unlink
Else
End If
If Me.ComboBox2.Value <> "" and Me.ComboBox3.Value <> "" Then
Selection.Wholestory
Selection.Fields.Unlink
End If
What I'm finding is that whilst the code runs fine and the unneeded documents are deleted, what I'm left with is a single blank page tacked onto the end of my document which reports as being the same section number as that just deleted. For instance, if I delete Section 3 automatically, I end up with blank page in place of Section 3, or if I delete Sections 2 and 3 I end up with a blank claiming to be Section 2.
Does anyone know why this blank page would exist? I've been through the entire document and confirmed that there are only section breaks where I want them. There are some content controls in the footer but I can't see how these would have any bearing.
Thanks in advance
Dav
I have a Word document broken down into three sections, each section containing the same basic document but with different DocVariables so that I can create up to three copies at a time, using different base information, i.e. name and address details for three different people.
In my current code ComboBox1 relates to Section 1; ComboBox 2 to Section 2; and ComboBox3 to Section 3. There will always be at least one version of my document created when running the macro and so I've focused on variables involving ComboBoxes 2 and 3.
IF Me.ComboBox2.Value = "" and Me.ComboBox3.Value = "" Then
ActiveDocument.Sections(3).Range.Delete
ActiveDocument.Sections(2).Range.Delete
Selection.WholeStory
Selection.Fields.Unlink
Else
End If
If Me.ComboBox2.Value <> "" and Me.ComboBox3.Value = "" Then
ActiveDocument.Sections(3).Range.Delete
Selection.WholeStory
Selection.Fields.Unlink
Else
End If
If Me.ComboBox2.Value <> "" and Me.ComboBox3.Value <> "" Then
Selection.Wholestory
Selection.Fields.Unlink
End If
What I'm finding is that whilst the code runs fine and the unneeded documents are deleted, what I'm left with is a single blank page tacked onto the end of my document which reports as being the same section number as that just deleted. For instance, if I delete Section 3 automatically, I end up with blank page in place of Section 3, or if I delete Sections 2 and 3 I end up with a blank claiming to be Section 2.
Does anyone know why this blank page would exist? I've been through the entire document and confirmed that there are only section breaks where I want them. There are some content controls in the footer but I can't see how these would have any bearing.
Thanks in advance
Dav