VB,怎么把一个文件夹中所有的文件的文件名导入到一个txt或者excel中?
展开全部
可以直接用SHELL+DOS命令
用记事本做一个1.bat文件,内容是:tree/f e:\小视频 >>d:\2.txt
然后在VB里:
Shell "e:\1.bat", vbHide
用记事本做一个1.bat文件,内容是:tree/f e:\小视频 >>d:\2.txt
然后在VB里:
Shell "e:\1.bat", vbHide
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim fs as filesystemobject
dim fsfolder as folder
dim fsfile as file
Dim xlApp As excel.Application
Dim xlBook As excel.Workbook
Dim xlSheet As excel.Worksheet
dim i as integer
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
Set fs = New FileSystemObject
set fsfolder =fs.getFolder("文件夹路径")
i=1
for each fsfile in fsfolder.files
xlSheet.cells(i,1) = fsfile.name
i=i+1
next
xlApp.visible=true
set fs =nothing
set fsfolder=nothing
set fsfile=nothing
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
dim fsfolder as folder
dim fsfile as file
Dim xlApp As excel.Application
Dim xlBook As excel.Workbook
Dim xlSheet As excel.Worksheet
dim i as integer
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
Set fs = New FileSystemObject
set fsfolder =fs.getFolder("文件夹路径")
i=1
for each fsfile in fsfolder.files
xlSheet.cells(i,1) = fsfile.name
i=i+1
next
xlApp.visible=true
set fs =nothing
set fsfolder=nothing
set fsfile=nothing
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
更多追问追答
追问
Dim xlApp As excel.Application用户定义类型未定义,我添加了引用Micrsoft Excel 11.0bject Library,还是不行,可否详解?
追答
我测试了,没报错。。按说你的11.0不会报错吧
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我写过一个获得选定文件夹下文件目录并保存为TXT的程序,你需要可以发给你,留个邮箱
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询