用EXCEL VBA获取指定目录下的文件名(包括文件夹名)
2个回答
展开全部
Sub xFolder()
Dim xPath As String
xPath = "F:\TMP\A"
exsitpath = Dir(xPath, vbDirectory)
If exsitpath <> "" Then
xs = Dir(xPath & "\" & "*.txt")
Do While xs <> ""
MsgBox xs '此处将获取到文件名,看你是准备写入表格,是其他代码
xs = Dir
Loop
End If
End Sub
Dim xPath As String
xPath = "F:\TMP\A"
exsitpath = Dir(xPath, vbDirectory)
If exsitpath <> "" Then
xs = Dir(xPath & "\" & "*.txt")
Do While xs <> ""
MsgBox xs '此处将获取到文件名,看你是准备写入表格,是其他代码
xs = Dir
Loop
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询