FileSys.CopyFile(mb, fl,True)
'ShowAppWindow("wps",5)
Dim app As New MSWord.Application
Try
Dim doc = app.Documents.Open(fl)
Dim tbl = doc.Tables.Add(Range:=app.Selection.Range, NumRows:=3, NumColumns:= 8)
'设置边框样式
' 设置表格边框样式
With tbl.Borders
.OutsideLineStyle = wdLineStyleSingle ' 设置外边框为单线
.OutsideLineWidth = wdLineWidth050pt ' 设置外边框宽度为 0.5 磅
.OutsideColor = RGB(0, 0, 0) ' 设置外边框颜色为黑色
.InsideLineStyle = wdLineStyleSingle ' 设置内边框为单线
.InsideLineWidth = wdLineWidth025pt ' 设置内边框宽度为 0.25 磅
.InsideColor = RGB(0, 0, 0) ' 设置内边框颜色为黑色
End With
' 设置表格第一行的字体加粗
tbl.Rows(1).Range.Font.Bold = True
Dim i As Integer
For i = 1 To tbl.Rows(1).Cells.Count
tbl.Rows(1).Cells(i).Shading.BackgroundPatternColor = RGB(189, 214, 238) ' 浅灰色 (Light Gray)
Next i
' 填充表格单元格
tbl.Columns(1).Width = 50 : tbl.Cell(1, 1).Range.Text = "序号"
tbl.Columns(2).Width = 50 : tbl.Cell(1, 2).Range.Text = "区域"
'替换指定字符串
doc.Content.Find.Execute(FindText:="序号", replacewith:="替换的文字", Replace:=2)
'打开文件
app.Visible = True
doc.save
Catch ex As exception
Output.Show(ex.message)
app.Quit
Finally
End Try
GC.Collect()
Output.Show(Date.Now & "结束执行")
'Return msg
老师,标红的两个都会报错