vb6.0中如何将datagrid打印到word上

来源:百度知道 编辑:UC知道 时间:2024/06/21 01:29:39
请教各位高手指点,谢谢!

0分,呵呵,怪不得没人回答
先添加对word的引用,然后你可以参考以下代码:
Private Sub cmdExport_Click()
Dim i As Integer, j As Integer
Dim ifieldcount As Integer, irecordcount As Integer
Dim wdapp As Word.Application
Dim wddoc As Word.Document
Dim atable As Word.Table
cmdFind_Click
If Adodc1.Recordset.RecordCount > 0 Then
irecordcount = Adodc1.Recordset.RecordCount
'创建word应用程序,这一句话打开word2000
Set wdapp = CreateObject("Word.Application")
'在word中添加一个新文档
Set wddoc = wdapp.Documents.Add
With wdapp
.Visible = True

.Activate
'在word中增加一个表格
.Caption = "送检表"
Set atable = .ActiveDocument.Tables.Add(.Selection.Range, irecordcount + 1, 7)
atable.Cell(1, 1).Range.InsertAfter "物资编号"
atable.Cell(1, 2).Range.InsertAfter "物资名称"
atable.Cell(1, 3).Range.InsertAfter "规格型号"
atab