ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use Current directory to store file (https://www.excelbanter.com/excel-programming/283668-use-current-directory-store-file.html)

Paul Moles[_2_]

Use Current directory to store file
 
In an earlier post I found a save as date macro:
(Thanks to Bob Phillips)

Sub SaveWithDate()
ActiveWorkbook.SaveAs Format(Date, "dd-mmm-yy")
End Sub

I also have

Sub SaveAs_Range()
ActiveWorkbook.SaveAs Filename:=Range("A1")
End Sub

Unfortunately they both default to saving in the user
default file location, Tools Options General setting.
Which for convenience may have been set to "My Documents",
with users navigating within.

Rather than from whence they came. c:\wherever\ might
even be d:\my documents\operator1\here ever\

I don't want to create a directory on the user machine, or
know that it already exists.

How do I get the macro to default to the source directory.

It is unlikely other files would be open at the same time,
polluting the "save as" path, but not impossible.
The file will be circulated allowing users to store in
their normal location. Following data entry, at end of
week an update will be stored in the same folder, both
macros give a new filename knowing the old file will not
be overwritten.

Ron de Bruin

Use Current directory to store file
 
If the file is saved ones you can use this

ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & Format(Date, "dd-mmm-yy")


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Paul Moles" wrote in message ...
In an earlier post I found a save as date macro:
(Thanks to Bob Phillips)

Sub SaveWithDate()
ActiveWorkbook.SaveAs Format(Date, "dd-mmm-yy")
End Sub

I also have

Sub SaveAs_Range()
ActiveWorkbook.SaveAs Filename:=Range("A1")
End Sub

Unfortunately they both default to saving in the user
default file location, Tools Options General setting.
Which for convenience may have been set to "My Documents",
with users navigating within.

Rather than from whence they came. c:\wherever\ might
even be d:\my documents\operator1\here ever\

I don't want to create a directory on the user machine, or
know that it already exists.

How do I get the macro to default to the source directory.

It is unlikely other files would be open at the same time,
polluting the "save as" path, but not impossible.
The file will be circulated allowing users to store in
their normal location. Following data entry, at end of
week an update will be stored in the same folder, both
macros give a new filename knowing the old file will not
be overwritten.





All times are GMT +1. The time now is 04:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com