如何用VB在word里绘制表并填入表数据

来源:百度知道 编辑:UC知道 时间:2024/06/07 23:13:48
用VB在word里绘制4行6列的表,并在表的指定格内写入数据,有点类似于在Excel里写一样。
有哪位神仙前来相助,在下感激不尽!!!

ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
6, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
Selection.Columns(1).Select '选中列
Selection.Rows(4).Select '选中行
Selection.TypeText Text:="插入数据"

分太少,关键代码在上面,你自己创建WORD对象吧,EXCEL会用,WORD也应该会!