PDA

View Full Version : Set default save path



rocheey
08-01-2008, 02:51 AM
Im my code (external from Excel), I want to open an existing .xls file as a template, write some data, but usually *not save it* - the data is meant to usually be temporary in nature - a snapshot of existing settings.

However, occasionally a user wants to save it - to a specific drive/path that would reflect where the program was originally launched from. This path will change, but I will always know it in advance.

Can excel be 'seeded' with this directory, so that if the user chooses to save, that the save dialog will display this path when the 'Save As' dialog appears?

Or maybe a work-around?

Thanks, guys

Bob Phillips
08-01-2008, 03:16 AM
Have you tried

Application.Path

rocheey
08-03-2008, 10:57 AM
Both Application.path, and Workbook.path, are read-only properties ... any other ideas?

mdmackillop
08-03-2008, 02:38 PM
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.EnableEvents = False
Cancel = True
Application.Dialogs(xlDialogSaveAs).Show ActiveWorkbook.Path
Application.EnableEvents = True
End Sub

Bob Phillips
08-03-2008, 03:36 PM
Both Application.path, and Workbook.path, are read-only properties ... any other ideas?

So?



ChDrive Application.Path
ChDir Application.Path

rocheey
08-03-2008, 03:38 PM
thats a nice route.

Unfortunately, this is a new workbook, being created from scratch, so it doesnt have a path property yet. I suppose I could modify the code to set the save dialog to my specific path, and I'm still considering this; but Im still hoping to have a 'dumb' spreadsheet saved, without any macros embedded (Im generating the spreadsheet from AutoCad/OLE)

I'd hoped there was just some setting that I could set once, for the initial save, then, if they optionally decided to save the workbook , instead of just closing without saving, then they wouldnt have to browse the network to find the the drive/folder where it's supposed to go.

If I dont use your method, then I'll probably just put an option button on the form that generates these reports, that gives the option to auto save to the correct path.

Thanks!

mdmackillop
08-03-2008, 03:51 PM
Why not create the new workbook from a template that contains the code? Any new book, however created will need to be saved with an identified path. I'm not clear how you are approaching this.