下面的保存的代码运行的时候可以弹出“保存”对话框,但是没有文件生成???
????急急急急急急急急急急急!
代码:
Private Sub save_Click()
On Error GoTo error2
Dim file As String
If Left$(ActiveForm.Caption, 5) = "未命名文档" Then
With CD
.DialogTitle = "保存"
.CancelError = True
.Flags = 2
.Filter = "写字板文件(*.rtf)|*.rtf|所有文件(*.*)|*.*"
.FileName = ActiveForm.Caption
.ShowSave
If Len(.FileName) = 0 Then
Exit Sub
Else
file = .FileName
End If
End With
Else
file = ActiveForm.Caption
End If
If Right$(file, 4) = ".txt" Then
ActiveForm.RichTextBox1.SaveFile , 1
ActiveForm.Caption = file
Else
ActiveForm.RichTextBox1.SaveFile , 0
ActiveForm.Caption = file
End If
error2:
If Err.Number = cdlCancel Then Exit Sub
End Sub