Saving a specific worksheet in csv by using Dialog box Save As, so that the user can choose the path

Gwhaou

Board Regular
Joined
May 10, 2022
Messages
78
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi,

Actually I'm using this code, to save a specific worksheet in CSV, on a predefined folder path, with this code the user can add the name for the file and it will be saved on the predefined path : here is on the desktop


VBA Code:
Public Sub Save_CSV()


Application.ScreenUpdating = False

Sheets("DATA_SHEET").Select
Dim N_fold As Variant
Dim Stock_N As String


On Error GoTo Canceled

N_fold = InputBox("Your file will be saved on the desktop.", "Save in CSV", "add a name to the file")

If StrPtr(N_fold) = 0 Then Exit Sub

Stock_N = N_fichier

With ActiveSheet

.Copy
ActiveWorkbook.SaveAs "C:\Users\Johnny\Desktop\" & Stock_N & "_" & .Name & ".csv", xlCSV, Local:=True
ActiveWorkbook.Close False
.Activate


End With


Canceled:
Application.ScreenUpdating = True

End Sub


I want to use dialog box (Save as) predefined on CSV format, sorry i'm new to vba 😥 i don't know how to use dialog box to save one particular sheet on csv when the user use that macro.
I need some help 🙏
 
Try setting the Local argument to True when saving...

VBA Code:
ActiveWorkbook.SaveAs FileName:=FileName, FileFormat:=xlCSV, Local:=True
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,214,403
Messages
6,119,309
Members
448,886
Latest member
GBCTeacher

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
Back
Top