select 某个文档变量如何删除?
How can i select certain document variable to delete?
下面的代码是删除所有文档variable.i想删除某个文档变量only.How我要设置条件吗?
'Remove all
Public Sub RemoveDocVariables(ByRef fileName As Object)
Using doc = WordprocessingDocument.Open(fileName, True)
doc.MainDocumentPart.DocumentSettingsPart.Settings.RemoveAllChildren(Of DocumentVariables)()
End Using
End Sub
您需要手动迭代集合
Public Sub RemoveDocVariables(ByRef fileName As Object)
Using doc = WordprocessingDocument.Open(fileName, True)
For Each DV As DocumentVariables In doc.MainDocumentPart.DocumentSettingsPart.Settings.OfType(Of DocumentVariables).ToArray()
If PlaceYourConditionHere Then doc.MainDocumentPart.DocumentSettingsPart.Settings.Remove(DV)
Next
End Using
End Sub
下面的代码是删除所有文档variable.i想删除某个文档变量only.How我要设置条件吗?
'Remove all
Public Sub RemoveDocVariables(ByRef fileName As Object)
Using doc = WordprocessingDocument.Open(fileName, True)
doc.MainDocumentPart.DocumentSettingsPart.Settings.RemoveAllChildren(Of DocumentVariables)()
End Using
End Sub
您需要手动迭代集合
Public Sub RemoveDocVariables(ByRef fileName As Object)
Using doc = WordprocessingDocument.Open(fileName, True)
For Each DV As DocumentVariables In doc.MainDocumentPart.DocumentSettingsPart.Settings.OfType(Of DocumentVariables).ToArray()
If PlaceYourConditionHere Then doc.MainDocumentPart.DocumentSettingsPart.Settings.Remove(DV)
Next
End Using
End Sub