saving

david hasslehof

New Member
Joined
Aug 17, 2006
Messages
28
I am trying to create a button which will let me print and save a file, I can do the printing bit but cannot save it, I want to save it under the name of cell f3 and c3. Is there any way this can be done???
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi,

this is the basic code
Code:
ThisWorkBook.SaveAs "fullname"
fullname will contain 3 parts
path
name
extension

parth could be the thisworkbook path
name will be in the cell
extension probably ".xls"


Code:
Sub Mysaveas()
Dim fName As String
Dim fPath As String

fPath = ThisWorkbook.Path
fName = Sheets(1).Range("C3")

ThisWorkbook.SaveAs fPath & Application.PathSeparator & fName & ".xls"

End Sub
hoping you will be able to use these "concatenation-tricks" in other circumstances

kind regards,
Erik
 
Upvote 0
start the Visual Basic Editor (via Menu Tools, Macro or press ALT+F11).
On the Insert menu in the VBE, click Module. (if necessary)
In the module (the white area at the right), paste your code

to run the code
click anywhere in the code and hit function key F5
or
via Excel menu: Tools / Macro / Macros (or hit Alt+F8)


assign shortcutkey
menu Tools/Macro/Macros
select your macro
click options
choose a character as shortcut: example T
to run the macro press Ctrl+Shift+T
 
Upvote 0
Sub Mysaveas()
Dim fName As String
Dim fPath As String

fPath = W:\RPD\DBrady\Excel\Special Deals\2006 Deals\quarter 3\September quotes

fName = Sheets(1).Range("f6")

ThisWorkbook.SaveAs fPath & Application.PathSeparator & fName & ".xls"

End Sub

I have put that in but it comes up as an error??
 
Upvote 0
you are very close

when recording you get something like
Code:
ActiveWorkbook.SaveAs Filename:="C:\WINDOWS\Desktop\anyfile.xls"
you need to keep the quotes !
"C:\WINDOWS\Desktop"
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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