excel vba如何以txt方式打开文本文件

ad440488 2011-06-22 03:20:31
如题
...全文
1372 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
z_wenqian 2011-06-23
  • 打赏
  • 举报
回复
Workbooks.OpenText Filename:="D:\a.txt", Origin:=936, StartRow:=1, _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter _
:=False, Tab:=False, Semicolon:=False, Comma:=False, Space:=False, _
Other:=False, FieldInfo:=Array(1, 2), TrailingMinusNumbers:=True

以txt方式打开d:\a.txt
  • 打赏
  • 举报
回复
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\alltext.txt", True)
for each page in ThisDocument.Pages
a.WriteLine("----页:"+page.name+"----")
for each shape in page.Shapes
a.WriteLine(shape.Text)
next
next
a.Close
Set a=Nothing
Set fs=Nothing

楼主自己查下联机帮助FSO部分有详解。
q260401998 2011-06-22
  • 打赏
  • 举报
回复
楼上的代码是什么意思?
怎么都是一行的呢?
是VB语句的么?
赵4老师 2011-06-22
  • 打赏
  • 举报
回复
仅供参考
?"begin...";: _
Set fs = CreateObject("Scripting.FileSystemObject"): _
Set a = fs.CreateTextFile("c:\alltext.txt", True): _
for each page in ThisDocument.Pages: _
a.WriteLine("----页:"+page.name+"----"): _
for each shape in page.Shapes: _
a.WriteLine(shape.Text): _
next: _
next: _
a.Close: _
Set a=Nothing: _
Set fs=Nothing: _
?"end"

2,503

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧