1
我想删除目录中的文件,然后目录如果用户提示的答案是否定的。在excel 2010 vba
下面,但是我在For
这行上得到一个语法错误。谢谢 :)。删除文件,然后在Excel 2010文件夹vba
Dim Directory As String
Dim MyFile As Variant
Dim MyFolder As String
Dim i As Long
iYesNo = MsgBox("Do the patients and barcode match the setup sheet?", vbYesNoCancel)
Select Case iYesNo
Case vbYes
GoTo Line2
Case vbNo
MsgBox ("Doesn't match! Please enter again")
MyFolder = Directory ' delete all txt files in the folder
MyFile = MyFolder & "*.txt"
For i = LBound(MyFile) To UBound(MyFile)
Kill MyFolder & MyFile(i)
Next
RmDir Directory ' delete folder
GoTo Line1
End Select
该目录设置为一个变量,当我逐步执行代码时,该变量似乎是正确的。
'myfile'只是一个字符串,不是数组,所以'i'是一个字符串,不是数字。看看'dir' – findwindow