|
-
Oct 29th, 2008, 01:00 PM
#1
Thread Starter
Lively Member
[RESOLVED] Excel "Save as" with path?
I am using this sub to save the active workbook:
Code:
Private Sub FileSave()
flFormat = ActiveWorkbook.FileFormat
flName = Range("D5").Value & ".xls"
flToSave = Application.GetSaveAsFilename(flName, filefilter:="Excel Files (*.xls), *.xls", _
Title:="Save FileAs...")
If flToSave = False Then
Exit Sub
Else
ThisWorkbook.SaveAs Filename:=flToSave, FileFormat:=flFormat
End If 'flToSave = False
End Sub 'FileSave()
but I can't figure out how to set the default directory to let's say "H:\Team A".
As there are lots of team members using the same template, I cant set up the name with the path included (e.g. Application.ActiveWorkbook.SaveAs "H:\Team A\John\Item.xls").
I found on the forums all kind of ideas, e.g. using ChDir, but none works.
Any suggestions will be appreciated.
Last edited by adifel; Oct 29th, 2008 at 01:03 PM.
-
Oct 29th, 2008, 03:59 PM
#2
Re: Excel "Save as" with path?
if flname ends in \ then the dialog will open the specified directory with no default file name
you can set the path as a variable and combine the path and file name, something like
Code:
mypath = "h:\team A\" & environ("username") &"\"
flToSave = Application.GetSaveAsFilename(mypath & flName, filefilter:="Excel Files (*.xls), *.xls", _
Title:="Save FileAs...")
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 29th, 2008, 04:11 PM
#3
Thread Starter
Lively Member
Re: Excel "Save as" with path?
Works like a charm (I tried that before but for some reason it didn't work...). Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|