Save As to a particular file location.

F

fmgamboa

I have having using a macro to "save as" to a particular file
location. For some reason it was working and now it always saves the
file to "my document". I don't know what happened. Below is the code,
with the location I want to save it at in "local". Any ideas?

Sub save()
ActiveWorkbook.SaveAs FileFormat:=51,
Filename:=Sheets("dashboard").Range("B6").Value & " Weekly Report " &
Format(Date, "mmdd"), Local:="N:\Aarons Team\TSA Core Reports"
End Sub
 
J

Jim Cone

Is FileFormat 51 an xl2007 file format? I can't find it in xl2002.
In any case, the file path should be part of the Filename.
So...
ActiveWorkbook.SaveAs FileFormat:=51, _
Filename:="N:\Aarons Team\TSA Core Reports\" & _
Sheets("dashboard").Range("B6").Value & _
" Weekly Report " & Format(Date, "mmdd")
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


<[email protected]>
wrote in message
I have having using a macro to "save as" to a particular file
location. For some reason it was working and now it always saves the
file to "my document". I don't know what happened. Below is the code,
with the location I want to save it at in "local". Any ideas?

Sub save()
ActiveWorkbook.SaveAs FileFormat:=51,
Filename:=Sheets("dashboard").Range("B6").Value & " Weekly Report " &
Format(Date, "mmdd"), Local:="N:\Aarons Team\TSA Core Reports"
End Sub
 
D

Dave Peterson

Maybe:

filename:="N:\Aarons Team\TSA Core Reports\" _
& Sheets("dashboard").Range("B6").Value & " Weekly Report " _
& Format(Date, "mmdd") & ".xlsx"

I think you'll want to read about what Local does in VBA's help under .saveas.
 
F

fmgamboa

Thanks! I just removed the two "_" dashes and your code worked. Yes,
file format 51 is 2007 format for a macro enabled workbook.
 
D

Dave Peterson

The space character followed by the underscore character is the continuation
character.

That means that the line doesn't have to extend to the far right (causing you to
scroll right/left to read it).

It can make it easier to read the code when you just have to scroll up/down.
 

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

Top