VBA - Let user save as file and close

jccnz

New Member
Joined
May 28, 2019
Messages
13
Hi There,
I created a button to allow user on mouse click save as file on their location but I want to close the workbook after save as.
are there any way to close after save as?
Code:
Private Sub Image1_Click()
Dim result As Variant
Dim activebook As Workbook
Application.DisplayAlerts = False

ThisWorkbook.Sheets("OpenOrder").Copy
result = Application.GetSaveAsFilename(FileFilter:="Excel File (*.csv), .csv", Title:="Save Excel")

If result <> 0 Then
ActiveWorkbook.SaveAs Filename:=result, FileFormat:=xlCSV
Application.DisplayAlerts = True

'ActiveWorkbook = "result" & ".csv"
'If Workbook_Name <> False Then
'ActiveWorkbook.SaveAs Filename:=Workbook_Name

ActiveWorkbook.Close savechanges:=False
End If
End Sub
 
Last edited by a moderator:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Watch MrExcel Video

Forum statistics

Threads
1,132,910
Messages
5,655,906
Members
418,250
Latest member
Jebacmakro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top