DataGrid表格发到WORD中打印出错,帮帮忙!(我刚注册,分不多,少了再加!在线等,)

Eagle136 2003-04-08 08:06:12
我想要打印DataGrid表格中的数据,参考了网上的代码写出来却错
我是这样写的:

DataGrid的名称是DataGrid1,有11个字段,还有表头。代码为

Private Sub Command3_Click()
Dim msWord As Object
Screen.MousePointer = 11
Set msWord = CreateObject("word.basic")
Dim AppID, Returnvalue
AppID = Shell("d:\office2000\office\WINWORD.EXE ", 1) '运行Word "
msWord.AppActivate "Microsoft winWord"
full
Screen.MousePointer = 0
End Sub

Sub full()
Dim i As Integer, j As Integer, col As Integer, row As Integer
Dim cellcontent As String
Me.Hide
Cols = 11 '表格的列数
row = gridrow '打印表的行数
msWord.filenewdefault
msWord.MsgBox "正在建立MS_WORD报表,请稍候…… ", "", -1
msWord.leftpara
msWord.screenupdating 0
msWord.tableinserttable , col, row, , , 16, 167
msWord.startofdocument
For j = 0 To gridrow '表格的行数
DataGrid1.row = j
For i = 1 To Cols
DataGrid1.col = i
If IsNull(Grid1.Text) Then
cellcontent$ = ""
Else
cellcontent$ = Grid1.Text
End If
msWord.Insert cellcontent$
msWord.nextcell
Next i
Next j
msWord.tabledeleterow
msWord.startofdocument
msWord.tableselectrow
msWord.tableheadings 1
msWord.centerpara
'msword.startdocument
msWord.screenrefresh
msWord.screenupdating 1
msWord.MsgBox "结束", "", -1
Me.Show 'End Sub
End Sub

运行时错误显示"'实时错误 504 :窗口不存在" 调试显示:
msWord.AppActivate "Microsoft winWord"
这一行高亮
请高手帮我看看是哪里没写好,谢了先!(我的WORD安装路径是
"d:\office2000\office\Winword.EXE")
...全文
17 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-04-08 08:06
社区公告
暂无公告