R
Robin Tucker
Hi,
I'm trying to split my document up into new documents, one for each section
in the original master document. To do this, I am more or less executing
the following code:
' Create a new document.
Dim theNewDocument As Word.Document =
m_WordApplication.Documents.Add(Visible:=True)
' Add the new document to the list of documents we should keep track of.
m_Sections.Add(theNewDocument)
' Get the current section.
theSection = m_LoadedDocument.Sections.Item(Index + 1)
' Now copy the section into the new document.
theRange = theSection.Range.FormattedText
' Copy across.
theNewDocument.Range.FormattedText = theRange
This is all well and good. Consider a master document with 2 sections. In
this case, the second (last) section is cut and copied correctly into the
new document, however, the first section when copied into the new document
still contains the section break at the end of it. So I am having to write:
' Got more than one section?
If theNewDocument.Sections.Count > 1 Then
' Somehow remove all section breaks from the document
End If
Any ideas on how to remove this section break?
Thanks,
Robin
I'm trying to split my document up into new documents, one for each section
in the original master document. To do this, I am more or less executing
the following code:
' Create a new document.
Dim theNewDocument As Word.Document =
m_WordApplication.Documents.Add(Visible:=True)
' Add the new document to the list of documents we should keep track of.
m_Sections.Add(theNewDocument)
' Get the current section.
theSection = m_LoadedDocument.Sections.Item(Index + 1)
' Now copy the section into the new document.
theRange = theSection.Range.FormattedText
' Copy across.
theNewDocument.Range.FormattedText = theRange
This is all well and good. Consider a master document with 2 sections. In
this case, the second (last) section is cut and copied correctly into the
new document, however, the first section when copied into the new document
still contains the section break at the end of it. So I am having to write:
' Got more than one section?
If theNewDocument.Sections.Count > 1 Then
' Somehow remove all section breaks from the document
End If
Any ideas on how to remove this section break?
Thanks,
Robin