GET SAVEAS FILE METHOD

MRTERMINAL

New Member
Joined
Nov 28, 2005
Messages
35
where do i add the filename in the following:



fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Text Files (*.txt), *.txt")
If fileSaveName <> False Then
MsgBox "Save as " & fileSaveName
End If
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
syntax from help file is:

expression.GetSaveAsFilename(InitialFilename, FileFilter, FilterIndex, Title, ButtonText)


Code:
fileSaveName = Application.GetSaveAsFilename("filename",  _ 
fileFilter:="Text Files (*.txt), *.txt") 
If fileSaveName <> False Then 
MsgBox "Save as " & fileSaveName
 
Upvote 0
saving files in csv format

Can someone tell me what i am doing wrong here:
i am trying to save the priceslu.xls file in priceslu.csv format and then delete some rows in the csv file and then save and close without the save message popping up but it's not working:

this is incomplete
Windows("PRICESLU2.xls").Activate
ChDir "G:\DAILY EQUITY MARKET PRICES"
ActiveWorkbook = Application.GetSaveAsFilename( _
fileFilter:="CSV Files (*.csv), *.csv")
If fileSaveName <> False Then
MsgBox "Save as " & fileSaveName
End If
Columns("F:BI").Select
Selection.Delete Shift:=xlToLeft
Range("AI20").Select
End Sub
 
Upvote 0
What part isn't working?

If it's to stop the save message just add:

Application.DisplayAlerts = False

to the top of your code.

HTH
 
Upvote 0
Well i just get the save as dialog box and but it won't save the activebook which is priceslu.xls into priceslu.csv. My formula currently is only able to display the save as box only.
 
Upvote 0
I'm not exactly sure what you're trying to accomplish but try this.

Code:
'turns off alerts
Application.DisplayAlerts = False
'stops screen flickering during update
Application.ScreenUpdating = False
'open workbook
Windows("PRICESLU2.xls").Activate 
'change to your sheet name
Sheets("Sheet1").Copy
'delete rows
Columns("F:BI").Select 
Selection.Delete Shift:=xlToLeft 
Range("AI20").Select 
'save in .csv format
Activeworkbook.SaveAs "Priceslu2.csv"

End Sub

This might get you started in the right direction
 
Upvote 0
MRTERMINAL

Could you please read the help file on GetSaveAsFileName?

The method does allow you to specify a filename, but it does not save the file, you need to do that yourself.

I'm sorry I can't go into the matter further but I would like some ZZZZZZZZZZ.
 
Upvote 0
THANKS VIPER AND NORIE

Thanks guys for helping me. I appreciate your kindness

Sorry I wasn't clear before

This is what i am trying to do:

I would like to create a personal macro to firstly save the file called priceslu.xls as priceslu.csv but i would like the user to be able to name the file before saving it in csv format because it changes everyday eg. priceslu28nov05.csv, priceslu29nov05.csv etc. I used the get saveas filename method but it is unable to save the priceslu.xls file. I just get a saveas box, I input the filename and click on the save button but the file doesn't actually get saved. I am new at writing macros and i am just learning so pardon my bad coding below:

ChDir "G:\DAILY EQUITY MARKET PRICES"
Application.DisplayAlerts = False
Windows("PRICESLU2.xls").Activate
Range("F10").Select
'save the priceslu.xls into user defined filename in csv format
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="CSV files (*.csv), *.csv")
If fileSaveName <> False Then
MsgBox "Save as " & fileSaveName
End If
"i just need help with above only"



Columns("F:BI").Select
Selection.Delete Shift:=xlToLeft
Range("AI20").Select
CreateBackup = False
ActiveWorkbook.Close
End Sub



 
Upvote 0
MRTERMINAL

The GetSaveAsName does exactly that it gets the name to save the file as, it doesn't save the file - you need to do that.
Code:
ActiveWorkboook.SaveAs fileSaveName
 
Upvote 0
Thanks Norrie for your patience

sorry Norrie... I am a bit thickheaded... I still don't understand how the getsaveas filename method works:

so do i type in the following as an example:

Workbooks.Open Filename:="G:\Book1.xls"
ActiveWorkbook.SaveAs filesavename = Application.GetSaveAsFilename("priceslu", _
fileFilter:="CSV files (*.csv), *.csv")

So does the code above open the file called book 1
and then saveas box pops up ...i name the file priceslu.csv and click on save....and then what do i do? because once i click on save i get a message saying that false.xls already exists..do you want to replace it and I click yes and then it saves the file as false.xls and not as priceslu.csv
 
Upvote 0

Forum statistics

Threads
1,219,161
Messages
6,146,657
Members
450,706
Latest member
LGVBPP

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