GetSaveAs command button - with specific address

csprod

New Member
Joined
Jul 17, 2011
Messages
2
Hello all you smart excel boffins !

I have just spent 3 hours searching for some VBA code that I can attach to a command button in excel to GETSAVEAS. Sounds simple enough, but I found none that can reference a particular cell in the spreadsheet for the file name.

My user is a novice and she often looses files as she dosent save them to the right directory or give them a decent name (lots of files called 'sheet1, sheet2, sheet3 on her computer!).

My spreadsheet has generated a unique file name (and directory) that is located in cell A1. (CELL A1 = "c:\users\craig\desktop\DaveJul2211.xls"). In subsequent sheets, the path stays the same, but the generated file name changes.

How do I run a GetSaveAs command and tell it to default to the file name and path that is in A1 ?. Also, force save as .xls file ?

Cheers,
Craig.
MSExcel 2000
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
For instance:

Code:
Sub fff()
    ActiveWorkbook.SaveAs [A1].Text, xlWorkbookNormal
End Sub
 
Upvote 0
No luck there unfortinately wigi...

This is what I have so far...

InitialFileName:="C:\users\craig\documents\companies\drivername_" & Range("A1").Value & ".xls", _
fileFilter:="Excel Workbook (*.xlsx),*.xlsx")

Cell A1 = BOB

but the file only saves as "C:\users\craig\documents\companies\drivername_.xls" - ie BOB (the unique name i want) is missing.

Any thoughts ?
 
Upvote 0
Hey csprod,
try using the following code:

Code:
Private Sub cmdSave_Click()
ActiveWorkbook.SaveAs Filename _
        :="C:\users\craig\documents\companies\drivername_" & Worksheets("Sheet1").Range("A1").Value, _
        FileFormat:=xlNormal, CreateBackup:=False
End Sub
(alter it where applicable)

Hope it works the way you want.

Cheers
Jan
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

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