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 作者: AlexLiu 时间: 2002-11-26 18:26
Cell(1, 2).Range.Text = Nz(rst("01"),"") 作者: tmtony 时间: 2017-9-11 11:25
加上NZ函数将null转为空白即可作者: fan0217 时间: 2017-9-12 21:56
nul陷阱