If you comment the Do While True line and the Loop line, your code will work. I think the reason you are getting the 'Unreachable' statement is because when you issue the following command: FD.FilePath = InitialFilePath, it initially sets the chosen file name to a blank string, so the condition is never True.