我有一个包含多个子文档的word 2007 .doc
文件,这些子文档由分节符分隔。
有没有一种方法可以从文档中删除所有分节符?
我尝试使用查找和替换功能,但是出现了错误。
private void RemoveAllSectionBreaks(Word.Document doc)
{
Word.Find find = doc.Range(ref oMissing, ref oMissing).Find;
find.ClearFormatting();
//find.Text = "^b"; // This line throws an error
find.Text =((char)12).ToString(); // Same error when attempting it this way
find.Replacement.ClearFormatting();
find.Replacement.Text = "";
find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, Word.WdReplace.wdReplaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
}
find.Text
这一行会导致错误 -
用户代码未处理的SEHException
外部组件引发了一个异常。
我无法获取任何关于可能出现的错误的更多细节。该代码在Word 2003中工作正常,但我需要它在Word 2007中工作。
我是否正在正确地处理Word 2007?