我正在使用 VB 2010 上的 DevExpress 2012 控件。我有一个富文本编辑控件,用作 Microsoft Word 的替代品。我正在加载一个包含标题的 Word 文档。我需要清除该标题并使用新数据重新创建它。我知道如何在新文档中插入带有数据的新标题,但我不知道如何清除现有标题。我没有办法做到这一点。以下代码不起作用。有任何想法吗?
Dim headerSection As Section = devWordControl.Document.Sections(0)
Dim subDoc As SubDocument = headerSection.BeginUpdateHeader(HeaderFooterType.First)
If headerSection.Margins.Left <> 170 Then
headerSection.Margins.Left = 170
End If
If headerSection.Margins.Right <> 130 Then
headerSection.Margins.Right = 130
End If
subDoc.SelectAll()
subDoc.Delete(subDoc.Range)
headerSection.EndUpdateHeader(subDoc)