I don't understand what the second parameter does. Seems no matter if I add multiple second parameters, nothing changes and code just works fine. But I don't understand why.
It would be awesome if I could see an example where I could test it to see the use of the second parameter in practice.
Thank you very much if you have an idea
This first part is ok:
But let's say I add a VbHidden or any other parameter (doesn't matter if its a folder or a file) --> nothing happens. If file exist, it won't launch, even if I set it to vbHidden or vbReadOnly. I would expect that it would not run since the specified file is neither Hidden neither ReadOnly.
It would be awesome if I could see an example where I could test it to see the use of the second parameter in practice.
Thank you very much if you have an idea
This first part is ok:
VBA Code:
Sub test()
If Dir("C:\Windows", vbNormal) = "" Then
cells(1,1).value = "Doesn't exist."
End If
End Sub
But let's say I add a VbHidden or any other parameter (doesn't matter if its a folder or a file) --> nothing happens. If file exist, it won't launch, even if I set it to vbHidden or vbReadOnly. I would expect that it would not run since the specified file is neither Hidden neither ReadOnly.
VBA Code:
Sub test2()
If Dir("C:\Folder\test.txt", vbNormal + vbReadOnly) = "" Then
cells(1,1).value = "Doesn't exist." 'this part never happens. If file exists, it is handled as existing even if it's not hidden or not read only.
else
msgbox "Exists" 'always this part runs
End If
End Sub