会员登录 - 用户注册 - 网站地图 Office中国(office-cn.net),专业Office论坛
当前位置:主页 > 技巧 > Access技巧 > OFFICE系统集成 > 正文

Access新增并将内容写入文本文件

时间:2003-12-20 22:46 来源:第十空间 作者:harsonli… 阅读:
以下用了两种方法。摘自harsonliao的火宇代码库源程序中

Sub MakeFile(strFile As String)
On Error GoTo err_section
'Dim fs As Object
'Dim a
Dim strPath As String

strPath = CurrentProject.Path
If Dir(strPath & "\Temp") = "" Then MakeSureDirectoryPathExists (strPath & "\Temp\")
'文件名及路径
strPath = strPath & "\Temp\Temp.txt"
'如文件已存在则删除
If Dir(strPath) <> "" Then Kill strPath

'Set fs = CreateObject("Scripting.FileSystemObject")
'Set a = fs.CreateTextFile(strPath, True)
'a.WriteLine (strFile)
'a.Close

Open strPath For Output As 1
Print #1, strFile
Close #1

exit_section:
Exit Sub

err_section:
MsgBox "Error in cmdBuild_Click - " & Err & " - " & Err.Description
Resume exit_section
End Sub

(责任编辑:admin)

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价: