Dim wbr As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
Dim tm As String = ProjectPath & "Attachments\11(不含表格).doc"
Dim fl As String = ProjectPath & "Reports\11(不含表格)doc"
Dim wrt As New WordReport(Tables("表AA"),tm,fl)
wrt.Build()
wrt.Quit()
Dim app As New MSWord.Application
try
Dim doc = app.Documents.Open(fl)
doc.Content.Find.Execute(FindText:="^l", replacewith:="^p", Replace:=2)
doc.Content.Find.Execute(FindText:="^13", replacewith:="^p", Replace:=2)
For Each k As object In doc.Paragraphs
k.Range.Select
If Len(k.Range.text) = 1 Then k.Range.Delete
Do
If app.Selection.Characters(1).Text = Chr(10) Then app.Selection.Characters(1).Delete
Loop Until app.Selection.Characters(1).Text <> Chr(10)
Next
'删除表格空行:
Dim tb As Object, r As Object
With Doc
For Each tb In .Tables
For Each r In tb.Rows
r.Range.Find.Execute(FindText:="^l", replacewith:="^p", Replace:=2)
r.Range.Find.Execute(FindText:=" ", replacewith:="", Replace:=2)
r.Range.Find.Execute(FindText:="^w", replacewith:="", Replace:=2)
If Len(Replace(Replace(r.Range.Text, vbCr, ""), Chr(7), "")) = 0 Then r.Delete
Next
Next
End With
doc.save
app.quit
catch ex As exception
msgbox(ex.message)
app.quit
End try
wbr.Address = fl