我有一个请求,我需要更新文本框填充颜色和找到特定文本的边框。
以下是我的代码的一部分。
For Each shape As DocumentFormat.OpenXml.Wordprocessing.Drawing In mainPart.Document.Body.Descendants.OfType(Of DocumentFormat.OpenXml.Wordprocessing.Drawing)()
'Replace date stamp with current date
'Find all placeholders that have mm/dd/yyyy as text.
If shape.Descendants.OfType(Of DocumentFormat.OpenXml.Wordprocessing.Text).Count() > 0 Then
If shape.Descendants.OfType(Of DocumentFormat.OpenXml.Wordprocessing.Text).First().InnerText = "mm/dd/yyyy" Then
LogVerboseMessage("Updating all date placeholders within document to current date")
Dim curDate As Date = Date.Now()
Dim curDateOnly As Date = curDate.Date
LogVerboseMessage("Shape has been found! Prepare to replace date.")
shape.Descendants.OfType(Of DocumentFormat.OpenXml.Wordprocessing.Text).First().Text = curDateOnly.ToString()
Dim color As String = shape.Descendants.OfType(Of DocumentFormat.OpenXml.Drawing.SolidFill).First.RgbColorModelHex.Val.ToString()
End If End If Next
当我在调试模式下运行上面的代码时,我得到了
"序列不包含任何元素"
错误消息。
我需要能够获取当前值并将其更新为新值。有人有什么建议吗?