i have these two codes for save
first
VB Code:
Private Sub Save_Click() CommonDialog1.Flags = cdlOFNOverwritePrompt With CommonDialog1 .CancelError = True .Filter = "Text files (*.txt)|*.txt" .DialogTitle = "Save the file..." CommonDialog1.Flags = cdlOFNOverwritePrompt .ShowSave If .filename <> "" Then RichTextBox1.SaveFile .filename, rtfText RichTextBox2.SaveFile Left(.filename, Len(.filename) - 4) & "first.txt", rtfText End If End With End Sub
second
VB Code:
Private Sub Command1_Click() With CommonDialog1 .CancelError = True .Filter = "Text files (*.txt)|*.txt" .DialogTitle = "Save the file..." .ShowSave If .filename <> "" Then If fso.fileexists(Left(.filename, Len(.filename) - 4) & "first.txt") Then Form1.RichTextBox1.LoadFile .filename, rtfText RichTextBox2.LoadFile Left(.filename, Len(.filename) - 4) & "first.txt", rtfText txtFileText.Text = RichTextBox2.Text Else MsgBox "This File is Not Tagged ,Please Select Another File!" Exit Sub End If End If End With End Sub
i'm getting an error when i click Cancel how can i avoid this error without
using any msgbox , i just need to cancel saving without effecting the project




Reply With Quote