Saving File Name based on cell value - Excel 2010

thenum1roc

Board Regular
Joined
Jun 2, 2002
Messages
77
I am trying to save an excel file based on some cell values in Excel 2010. I have done it before in 03' and 07' with success; however, for whatever reason the selection prompt comes up, with the file name from the cells, and I press save (NO ERROR RECEIVED)


.........BUT...........I don't see a file in any location where I attempt to save the file.


Please see the code below, Thanks.


Sub cmd_SaveToC_Drive()


Dim strPath As String
Dim strFolderPath As String

strFolderPath = "C:\"
ThisFile = Range("F12").Value & "_" & Range("L12").Value & "_" & Range("F14").Value & ".xls"

fileSaveName = Application.GetSaveAsFilename(InitialFileName:=strFolderPath & ThisFile)

End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try

Code:
Sub cmd_SaveToC_Drive()


Dim strPath As String
Dim strFolderPath As String
Dim fileSaveName As Variant
strFolderPath = "C:\"
ThisFile = Range("F12").Value & "_" & Range("L12").Value & "_" & Range("F14").Value & ".xls"

fileSaveName = Application.GetSaveAsFilename(InitialFileName:=strFolderPath & ThisFile)
If fileSaveName = False Then Exit Sub
ActiveWorkbook.SaveAs Filename:=fileSaveName

End Sub
 
Upvote 0
Application.GetSaveAsFilename only returns the file name. You then have to SaveAs that name.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,882
Members
452,948
Latest member
Dupuhini

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