我想在運行我的代碼之前檢查文件是否已經存在。如果它存在比退出,否則保持我的代碼運行。我寫的是下面的代碼:我如何檢查文件是否存在使用Powerpoint中的VBA宏
Private Sub CommandButton21_Click()
If FileFolderExists("C:\Users\Moez\Desktop\Macro_Project\Test1.pptm") Then
MsgBox "Modification already done!"
Else
deleteTextBox
AllBlackAndDate
LastModifiedDate
SaveAllPresentations "C:\Users\Moez\Desktop\Macro_Project\Test1.pptm" ' save here
End If
End Sub
的可能的複製[檢查文件是否存在使用VBA(http://stackoverflow.com/questions/11573914/check-if-the-file-exists-using-vba) – vacip
嘗試谷歌下一次。這已經在這裏被提出了一百次 - 這只是今年。 :) [1](http://stackoverflow.com/questions/16351249/vba-check-if-file-exists)[2](http://stackoverflow.com/questions/26551757/how-doi-i- check-if-a-file-exists-before-i-open-it-via-excel-vba)[3](http://stackoverflow.com/questions/4082539/how-do-i-determine-if- file-exists-vba-excel-2007)[4](http://stackoverflow.com/questions/35712855/test-if-file-exists-using-vba-or-excel-without-dir) – vacip
' CommandButton21' ...考慮*命名*的東西。 ''TimestampAndSaveButton'(或其他)將在六個月後從'CommandButton42'中更容易分辨出來。 –