设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

1970-1-1 08:00| 发布者: harsonliao| 查看: 1820| 评论: 0

以下用了两种方法。摘自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

最新评论

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-30 09:03 , Processed in 0.071080 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部