How to change the directory when using saveas dialog

jproffer

Well-known Member
Joined
Dec 15, 2004
Messages
2,647
Hi folks,

I can't quite figure this out, but I think (hope) I'm close. I'm trying to force the Save As dialog box to change to the "T:\SUPERVISORS REPORTS" directory after the rest of the code is finished. I'm just not quite sure where (or if that's even the correct way to do it) to put the second line of the code below (The "ChDir" line).

If anyone can fix this up, or tell me how to...or if you have another, better way, I'm all for that too.

Code:
Application.Dialogs(xlDialogSaveAs).Show (StrConv(TextBox1.Value, vbProperCase) & " " & Format(Year(Now()), yyyy) & ".xlsm")
    ChDir "T:\SUPERVISOR REPORTS"

Thank you for any help you can give :)
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
.
This is one way :

In your existing macro, where you want to change the SAVE AS command to another folder, insert the name of this macro Example5 :

Code:
Sub Example5()
Dim varResult As Variant
'displays the save file dialog
varResult = Application.GetSaveAsFilename(FileFilter:= _
"Excel Files (*.xlsx), *.xlsx, Macro Enabled Workbook" & _
"(*.xlsm), *xlsm", Title:="Some Random Title", _
InitialFileName:="C:\Users\logit\Desktop\Clocks") '<---------------------- edit this path for the desired new folder location
'checks to make sure the user hasn't canceled the dialog
If varResult <> False Then
Cells(2, 1) = varResult
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,345
Messages
6,124,408
Members
449,157
Latest member
mytux

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top