On Error GoTo err_startword
Dim wrd As New Word.Application, isrunning As Boolean
Dim tableNew As Table, tableNew1 As Table
Dim dbMyDB As Database, rst As Recordset, rst1 As Recordset
isrunning = True
wrd.Documents.Open fileName:="D:\Documents and Settings\ysc\My Documents\djb"
wrd.Visible = True
Set tableNew = ActiveDocument.Tables(1)
Set dbMyDB = CurrentDb
Set rst = dbMyDB.OpenRecordset("jijan1", dbOpenSnapshot)
rst.MoveFirst
With tableNew
.Cell(1, 2).Range.Text = rst("01")
.Cell(1, 2).FitText = True
.Cell(1, 4).Range.Text = rst("02")
End With
If isrunning = False Then
wrd.Quit
End If
Exit Sub
err_startword:
If Err.Number = 429 Then
Set wrd = CreateObject("word.application")
isrunning = True
Resume Next
Else
MsgBox Err.Number & "" & Err.Description
Exit Sub
End If
End Sub作者: zhengjialon 时间: 2002-11-26 00:42
空值,你可以用一个空格代替。作者: guotianxin 时间: 2002-11-27 00:16
如何解决“非法引用null"值的错误
我做了一个小程序,准备向WORD的表中填加数据库中的字段值,但是出现了一个小问题,当字有数据时,没有问题,但是当没有数据是提示我“非法引用NULL值”,我应该如何处理,就象邮件合并是,没数据,只显示为空的单元格。因为字段很多,不能每个都去判断是否为NULL
Sub startword()
On Error GoTo err_startword
Dim wrd As New Word.Application, isrunning As Boolean
Dim tableNew As Table, tableNew1 As Table
Dim dbMyDB As Database, rst As Recordset, rst1 As Recordset
isrunning = True
wrd.Documents.Open fileName:="D:\Documents and Settings\ysc\My Documents\djb"
wrd.Visible = True
Set tableNew = ActiveDocument.Tables(1)
Set dbMyDB = CurrentDb
Set rst = dbMyDB.OpenRecordset("jijan1", dbOpenSnapshot)
rst.MoveFirst