Saving into new directory

  • Thread starter Thread starter Greg B
  • Start date Start date
G

Greg B

Hi Want to save workbooks into archive when finished with i went through the
manual mode and would like to know, What do I have to change in this code so
it keeps the current file name etc greg.xls so on and so on.


ChDir "C:\idsc\archived"
ActiveWorkbook.SaveAs Filename:="C:\idsc\archived\Book1.xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
Range("G3").Select
End Sub
\

Thanks in advance

Greg
 
Right after the Sub( ) line at the top, add this line to declare a
variable that holds your workbook name:

Dim CurrentFileName as string
CurrentFileName = activeworkbook.name

Then change
ActiveWorkbook.SaveAs Filename:="C:\idsc\archived\Book1.xls",

.... to this:
ActiveWorkbook.SaveAs Filename:="C:\idsc\archived\" & CurrentFileName,


Note this changes your default directory to C:\IDSC\Archived, and the
active sheet, now on your screen, is your archive copy. This leaves
you open to inadvertently changing your archive copy, or treating it as
your main version. If that's not OK, let us know and we can add code
to get it to work to your specifications.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top