Below are the codes of Save and SaveAs ...
but once i open a file(to input data in the program)... when i select SaveAs... a save dialog will pop up.. but when i select "cancel"... a error msg "Cancel was selected" will pop up... am i missing something in the code??
Public Sub mnuSave_Click()
'if the user has previously selected a file then save it
If Fil <> "" Then
Save
Else
'the user hasn't selected a file so make them select one
mnuSaveAs_Click
End If
End Sub
Public Sub mnuSaveAs_Click()
' the function to get the filename
Fil = GetFileName
'only let the user save if they selected a file
If Fil <> "" Then
Save
End If
End Sub
Public Function GetFileName() As String
With CommonDialog1
.FileName = "" 'Clear out the dialog box's filename
.DialogTitle = "Save As"
.ShowSave
End With
GetFileName = CommonDialog1.FileName
End Function
but once i open a file(to input data in the program)... when i select SaveAs... a save dialog will pop up.. but when i select "cancel"... a error msg "Cancel was selected" will pop up... am i missing something in the code??
Public Sub mnuSave_Click()
'if the user has previously selected a file then save it
If Fil <> "" Then
Save
Else
'the user hasn't selected a file so make them select one
mnuSaveAs_Click
End If
End Sub
Public Sub mnuSaveAs_Click()
' the function to get the filename
Fil = GetFileName
'only let the user save if they selected a file
If Fil <> "" Then
Save
End If
End Sub
Public Function GetFileName() As String
With CommonDialog1
.FileName = "" 'Clear out the dialog box's filename
.DialogTitle = "Save As"
.ShowSave
End With
GetFileName = CommonDialog1.FileName
End Function