Sub CloseFile(Filename As String) Dim rCode As Integer, FileNum As Integer On Error GoTo CloseError ' Display the error message below. If Dir(Filename) <> "" Then ' File exists, prompt for overwrite rCode = MsgBox("Overwrite " & Filename & "?", vbYesNoCancel, "File Exists") Select Case rCode Case vbYes 'Do nothing just keep going Case vbNo Exit Sub Case vbCancel Exit Sub End Select End If FileNum = FreeFile Open Filename For Output As FileNum 'Open the file Print #FileNum, Text1.Text 'Print whatever (text1.text for example) Close FileNum 'Close the file Exit Sub CloseError: rCode = MsgBox("Error occurred trying to close " & Filename, vbRetryCancel, "Error writing " & Filename) Select Case rCode Case vbCancel Exit Sub Case vbRetry CloseFile (Filename) End Select Exit Sub End Sub