Sub GetFolder() Dim FolderName, FileName, MyFolder, MyFile As String FolderName = "abc" FileName = "abc.xls" MyFolder = Dir("D:\" & FolderName, 16) MyFile = Dir("D:\" & FolderName & "\" & FileName, 16) If MyFolder <> "" Then MsgBox "The folder is OK" Else MkDir "D:\" & FolderName End If If MyFile <> "" Then MsgBox "The File is OK" Else Open "D:\" & FolderName & "\" & FileName For Output As #1 Close #1 End IfEnd Sub
Sub GetFolder() Dim FolderName, FileName, MyFolder, MyFile As String FolderName = "abc" FileName = "abc.xls" MyFolder = Dir("D:\" & FolderName, 16) MyFile = Dir("D:\" & FolderName & "\" & FileName, 16) If MyFolder <> "" Then MsgBox "The folder is OK" Else MkDir "D:\" & FolderName End If If MyFile <> "" Then MsgBox "The File is OK" Else Open "D:\" & FolderName & "\" & FileName For Output As #1 Close #1 End IfEnd Sub