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