Private Sub Form_Load() With CommonDialog1 .FileName = "" .Flags = cdlOFNOverwritePrompt .CancelError = True End With End SubPrivate Sub mnuSave_Click() On Error Goto errexit With CommonDialog1 If .FileName = "" Then .DialogTitle = "保存" .ShowSave End If If .FileName > "" then '在这里写保存代码 End If End With errexit: End SubPrivate Sub mnuSaveAs_Click() On Error Goto errexit With CommonDialog1 .DialogTitle = "另存为" .ShowSave If .FileName > "" then '在这里写保存代码 End If End With errexit: End Sub
With CommonDialog1
.FileName = ""
.Flags = cdlOFNOverwritePrompt
.CancelError = True
End With
End SubPrivate Sub mnuSave_Click()
On Error Goto errexit
With CommonDialog1
If .FileName = "" Then
.DialogTitle = "保存"
.ShowSave
End If
If .FileName > "" then
'在这里写保存代码
End If
End With
errexit:
End SubPrivate Sub mnuSaveAs_Click()
On Error Goto errexit
With CommonDialog1
.DialogTitle = "另存为"
.ShowSave
If .FileName > "" then
'在这里写保存代码
End If
End With
errexit:
End Sub