I am trying to suppress the following message box from occurring or have it go to the error message line if it does occur. " Sorry we couldn't find xxx is it possible if it was moved..."
Normally I would check if the dir(Folderpath & Filename) <> 0. However, these files are on a sharepoint server. So regardless of whether the files exist or not I get a runtime 52 error: "Error 52: Bad filename or number." This error occurs when launching an FRx install that points to a network SysData directory."
Where I am confused is the below snippet works if the file exist.
Set stateWb = Workbooks.Open(folderPath & fileName)
However, if it does not exist I receive the " Sorry we couldn't find xxx is it possible if it was moved...". The goal is that if the workbooks.open fails, go to error message and print the following msgBox " State Data not available".
Currently it does both it gives the message " Sorry we couldn't find xxx is it possible if it was moved..." and also produces the msgbox " State Data not available".
Thoughts?
dir(Folderpath & Filename) <> 0
withdir(Folderpath & Filename) <> ""
.Dir
returns a string. And be sure that betweenFolderpath
andFilename
it is a back slash character. – FaneDuru