Macro code for SaveAs
Hi !!
I have a macro code to save my invoices but I want to change it.
In my invoice template, A12= John Smith // C11= 10/01/2012 // C12= 00000002, and my current code is:
Sub SaveAs()
ThisFile = Range("C12").Value & Range("A12").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub
This code save my invoices as: 2John Smith.
I want change the file name to "Inv 2 John Smith 10-01-12"
Can someone help me?
Thank you,
»
- Add new comment
- 427 reads

Sub SaveAs() InvNb =
Sub SaveAs()
InvNb = Range("C12").Value
InvName = Range("A12").Value
InvDate = format(Range("C11").Value,"dd-mm-yy")
ThisFile = "Inv " & InvNb & " " & InvName & " " & InvDate
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub
Macro SaveAs
Thanks Nick for the code.
I forgot to ask also to insert the location of the file, for example C:\my documents\invoices
Can you please add it to the code ??
Also, I'm trying to create this same macro in a different worksheet, so I go to macro, record macro when I try to run I'm getting this msg: "The folowing features cannot be saved in macro-free workbooks: VB projects"
What does it mean?? How to make it to work??
Thank you
Change needed: ThisFile =
Change needed:
ThisFile = "C:\my documents\invoices\" &
"Inv " & InvNb & " " & InvName & " " & InvDate
if you want it to be an Excel file, you also need to add: & ".xls" at the end
you need to save the file as an xls, or xlsm... at the moment, it's prob an xlsx.
Macro SaveAs
Thanks Nick
More than one ThisFile
Is it possible to have more than one ThisFile=Range() references? If so, what else could you refer to it as?
yes of course.. you can call
yes of course.. you can call it whatever you want..
how about: ThisFile1 ?!...