如下代码
'''
If DataTables("通知单").Select("标注 = true").count = 0 Then
Dim Result As DialogResult
Result = MessageBox.Show("你没有选中数据,请勾选复选框!"& vbcrlf &"是---返回"& vbcrlf &"否---关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Return
Else
Return
End If
End If
If DataTables("通知单").Select("标注 = true").count > 0 Then
For Each r As Row In Tables("通知单") '显示标注
Tables("通知单").Filter = "标注 = True"
Next
Dim mb As String = FileSys.ReadAllText(ProjectPath & "初始模板.html")
Dim tbl As Table = Tables("通知单") '选中的多行
Dim str As String = ""
'For i As Integer = tbl.TopRow To tbl.BottomRow
For Each r As DataRow In DataTables("通知单").Select("标注 = true")
Dim s = mb
'Dim r As Row = tbl.Rows(i)
str &= s.Replace("(绑定编号)",r("编号")).Replace("(绑定html_内容)",r("html_内容")).Replace("../","./").Replace("(绑定html_要求)",r("html_要求")).Replace("../","./")
Next
Dim txt As String = str
Dim pattern As String = "<img .+?/>"
Dim rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
For Each match As System.Text.RegularExpressions.Match In rgx.Matches(txt)
Dim s As String = match.Value
Dim w As Integer = -1
Dim h As Integer = -1
Dim mc = System.Text.RegularExpressions.Regex.Matches(s, "(?<=width:)[0-9]+(?=px)")
If mc.count > 0 Then
w = mc(0).value
End If
mc = System.Text.RegularExpressions.Regex.Matches(s, "(?<=height:)[0-9]+(?=px)")
If mc.count > 0 Then
h = mc(0).value
End If
If w <> -1 Then
s = System.Text.RegularExpressions.Regex.replace(s, "width=\"".*?\""", "width=""" & w & """")
s = System.Text.RegularExpressions.Regex.replace(s, "height=\"".*?\""", "height=""" & h & """")
'msgbox(s)
str = str.replace(match.Value, s)
End If
Next
str = "<body><html>" & str & "</body></html>"
FileSys.WriteAllText(ProjectPath & "新模板.doc", str, False)
End If
Dim app As New MSWord.Application
Dim Doc = app.Documents.open(ProjectPath & "新模板.doc")
Doc.saveas(FileName:=projectpath & "Attachments/" & "新.doc", FileFormat:=0)
app.ActiveWindow.ActivePane.View.Type = MSWord.WdViewType.wdPrintView
app.visible = True