2个问题,请教大家

icebound1 2003-07-18 09:10:27
1.怎么把一个word文档中的内容,写到.txt文本中
2.如何对一个目录中的所有文件遍历访问,例如,一个文件夹里有多个.txt文本文件 (c:\mytxt\...)如何编程对其中的所有.txt文件访问,文件命名没有规则


多谢大家
...全文
47 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lihonggen0 2003-07-19
  • 打赏
  • 举报
回复

Private Sub Command1_Click()
Dim I As Integer
sname = Dir("c:\test\*.txt")

Do While Len(sname) > 0
I = I + 1
Debug.Print sname
sname = Dir
Loop
MsgBox I
End Sub
vansoft 2003-07-19
  • 打赏
  • 举报
回复
Question one:
在VB中引用一个WORD对象。
wtty9822 2003-07-19
  • 打赏
  • 举报
回复
1.第一个问题 如何解决尚不清楚
2.用了7个控件1个窗体
"command1""list1""list2""dir1""drive1""label1""file1"
代码如下"
Private Sub Command1_Click()
'Clear lists
List1.Clear
List2.Clear
'Set path to root directory
Dir1.Path = Left$(Drive1.Drive, 2) + "\"
File1.Path = Dir1.Path 'Set file path
'Add files in root directory to catalog
For t& = 0 To File1.ListCount - 1
List2.AddItem Dir1.Path + File1.List(t&)
Next
'Add initial subdirectories in root
For t& = 0 To Dir1.ListCount - 1
List1.AddItem Dir1.List(t&)
Next
If t& = 0 Then GoTo finishedpoint 'No subdirectories, we're done.cnt& = 0 'Start with first directory in list
startpoint:
Dir1.Path = List1.List(cnt&)
File1.Path = Dir1.Path
'Add any subdirectories found
For t& = 0 To Dir1.ListCount - 1
List1.AddItem Dir1.List(t&)
Next
'Now add files found...
For t& = 0 To File1.ListCount - 1
List2.AddItem Dir1.Path + "\" + File1.List(t&)
Next
'Increment count
cnt& = cnt& + 1
If cnt& < List1.ListCount Then GoTo startpoint
finishedpoint:
Label1.Caption = "Total:" + Str$(List2.ListCount)
End Sub
xinxinyu2000 2003-07-19
  • 打赏
  • 举报
回复
filesystemobject
icebound1 2003-07-19
  • 打赏
  • 举报
回复
没有人帮我吗?
icebound1 2003-07-19
  • 打赏
  • 举报
回复
各位鼎立相助,感激不尽,多谢!!!

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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