Dim txt As String = "ABC"
Dim tm As String = ProjectPath & "Attachments\FabricWeight-EN.doc" '指定模板文件
Dim fl As String = ProjectPath & "Reports\FabricWeight.Doc" '指定目标文件
Dim wrt As New WordReport(Tables("FW_Gammage_Report"), tm, fl) '定义一个WordReport
wrt.Build()
wrt.Quit
Dim app As New MSWord.Application
Try
Dim fileName = ProjectPath & "Reports\FabricWeight.Doc" '指定目标文件
Dim doc As Object = app.Documents.Open(fileName)
app.Activedocument.Bookmarks("TestList").Range.Tables(1).Select
For Each zr As Row In Tables("FW_Gammage_Report").Rows
app.Selection.InsertRowsBelow(1)
app.Selection.Font.Bold = 0
app.Selection.MoveRight(Unit:=12)
app.Selection.TypeText(Text:=zr("分板号"))
app.Selection.MoveRight(Unit:=12)
app.Selection.TypeText(Text:=zr("EN客户要求"))
app.Selection.MoveRight(Unit:=12)
app.Selection.TypeText(Text:=zr("EN测试结果"))
app.Selection.MoveRight(Unit:=12)
app.Selection.TypeText(Text:=zr("EN结论"))
Next
app.ActiveWindow.ActivePane.View.SeekView = MSWord.WdSeekView.wdSeekMainDocument
app.Visible = True
Catch ex As exception
msgbox(ex.message)
app.Quit
Finally
'app.Quit
End Try
如果表格中 zr(“EN测试结果”)= 0.5cm2,想在生成的报表中cm2中的2能上标,请问应该如何处理?
https://www.baidu.com/s?wd=vb.net%20word%20%E4%B8%8A%E6%A0%87
试试
app.Selection.TypeText(Text:=zr("EN测试结果").replace("cm2","cm" & ChrW(&H00B2)))