访问2007 vba:dir不起作用?

时间:2013-08-06 05:21:15

标签: access-vba

我正在尝试使用dir函数获取一个简单的文件列表,结果只返回1个文件,即使它们有200个。任何想法我可能会在以下功能中缺少什么?

选项比较数据库

Public Sub getList()
Const strFolder As String = "c:\Users\bob\Desktop\social\"
Dim strFile As String
'strFile = Dir(strFolder & strPattern, vbNormal)
strFile = Dir(strFolder, vbNormal)
Debug.Print strFile
Do While Len(strFile) > 0
    Debug.Print strFile
    strFile = Dir()
Loop
End Sub

1 个答案:

答案 0 :(得分:0)

&符号显示对我来说很好。也许有一个不同的角色会导致问题。尝试替换此行

strFile = Dir(strFolder, vbNormal)

有了这个,

strFile = Replace(Dir(strFolder, vbNormal), "&", Chr(37))

然后改变&和Chr(37)用他们的chr等价物替换其他奇怪的角色,那么也许你可以找出问题。

相关问题