疼痛患者护理ppt:求助,VB调用WORD时候出问题了

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 01:33:01
小弟做了一个窗体,上边有2个文本框和一个按钮,要求一点按钮就会在"ABC\"文件夹生成以text1.text为文件名的包含text2.text的一个.doc文档,并调用WORD打开他,可我运行的时候第一遍没问题,等再运行第2遍的时候就提示我有错误,说是远程服务器关闭或文件不存在,不知道为什么,代码如下,希望哪位大侠帮我看看什么原因

Private Sub Command3_Click()
Dim filePath As String

filePath = App.Path

If Right(filePath, 1) <> "\" Then
filePath = filePath & "\ABC\"
Else
filePath = filePath & "ABC\"
End If

If Dir(filePath) = "" Then
MkDir filePath
End If

filePath = filePath & Trim(Text1.Text) & ".doc"

Dim fileNo As Long
fileNo = FreeFile
Open filePath For Output As #fileNo
Print #fileNo, text2.Text
Close #fileNo

Dim documents As Object
Set wdApp = New Word.Application
wdApp.Visible = True

Set documents = Word.documents.Open(App.Path & "\ABC\" + Text1.Text + ".doc")
Set wrd = Nothing

End Sub
有人说好象是什么内存没释放什么的,我也不懂..什么什么没释放..

把这句去掉试试~
Set wrd = Nothing