Button to export file as csv to fodle location

bobert1980

Active Member
Joined
Feb 1, 2012
Messages
255
I'm looking for some VBA code I can attach to a button which will automatically save the first worksheet of an excel file with its existing name but in csv format to the folder location 'O:\PHP\SAGE\Journals'. I'd like this to happen with no messages displayed, just an auto thing.

many thanks in advance
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
try

<CODE>
sub saveme()

ThisWorkbook.Worksheets("SHEET NAME HERE").Copy
ActiveWorkbook.SaveAs Filename:="O:\PHP\SAGE\Journals\file.csv", FileFormat:=xlCSVWindows

end sub
<CODE>
 
Upvote 0
try

<CODE>
sub saveme()

ThisWorkbook.Worksheets("SHEET NAME HERE").Copy
ActiveWorkbook.SaveAs Filename:="O:\PHP\SAGE\Journals\file.csv", FileFormat:=xlCSVWindows

end sub
<CODE>

Instead of file.csv it needs to be the current file name. Pop-up messages need to be turned off too. It also needs to be the first worksheet regardless of the name.

thanks

</CODE></CODE>
 
Upvote 0
This should do it.
Sub saveme()
Application.DisplayAlerts = false
Sheets(1).Select
ActiveWorkbook.SaveAs Filename:="O:\PHP\SAGE\Journals\" & Sheets(1).Name & ".csv", FileFormat:=xlCSVWindows
Application.DisplayAlerts = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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