Function ResolveNewFile(strNewFile, strErrorMessage) 'As String 'This function will return the full path and file name of a supplied file name. 'strNewFile = User input of a file name. 'strErrorMessage = This value will be modified to contain an error message if the function fails. Dim fs Set fs = CreateObject("Scripting.FileSystemObject") If Instr(strNewFile, ":\") = 2 Then 'Full path supplied with output file If fs.FileExists(strNewFile) Then 'Output file exists If MsgBox("Overwrite the existing """ & strNewFile & """ file?", vbYesNo, "Replace Existing File?") = vbYes Then ResolveNewFile = strNewFile fs.DeleteFile strNewFile, True Exit Function Else 'User bailed out to save existing file strErrorMessage = "User canceled action." ResolveNewFile = "" Exit Function End If Else 'Output file does not exist If fs.FolderExists(fs.GetParentFolderName(strNewFile)) Then 'Output folder exists. ResolveNewFile = strNewFile Exit Function Else 'Output folder does not exist strErrorMessage = "The folder """ & fs.GetParentFolderName(strNewFile) & """ does not exist." ResolveNewFile = "" Exit Function End If End If Else 'No path supplied with input file strErrorMessage = "Unable to determine full path of file." ResolveNewFile = "" Exit Function End If 'Should never get here strErrorMessage = "Unexpected coding error resolving PDB file name. Oops." ResolveNewFile = "" End Function