如何用EXCEL的VBA代码关闭已经打开的文本文件?

[复制链接]
查看11 | 回复2 | 2017-12-27 23:48:03 | 显示全部楼层 |阅读模式
给你举个例子:Sub test11()
Open ThisWorkbook.Path & "\output.txt" For Output As #1
'在#1打开当前文件夹中的output.txt文件
str1 = "123"
str2 = "你好吗"
str3 = "hello"
Print #1, str1, str2, str3, Date
'写入内容
Write #1, str1, str2, str3, Date
'写入内容
Close #1
'关闭#1这个文件End Sub程序会在output.txt文件内生成两列内容如下:123
你好吗
...
回复

使用道具 举报

千问 | 2017-12-27 23:48:03 | 显示全部楼层
怎么打开的,就怎么关闭,只是一个open,一个close...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行