SaveAs user to choose name

coop123

Board Regular
Joined
Dec 18, 2018
Messages
66
Office Version
  1. 365
I want to save the file produced from a macro to a specific folder and allow the user to enter the file name.

I have this code already but it is not working correctly.

Dim wb As Boolean
ChDir "J:\Material Type\Report files"
wb = Application.Dialogs(xlDialogSaveAs).Show

It will open up directory J:\Material Type, but won't open up directory J:\Material Type\Report files

Am I missing something or should I be using different code.

Any guidance would be much appreciated.

Thanks

Coop123
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Works for me. Does that folder exist and is named exactly like that?
 
Upvote 0
I have copied path exactly out of Explorer J:\Material Type\Report files, but it still only opens up to J:\Material Type, so I then have to manually expand Report files within material type.

Do you know of any possible reason why the code will only go to one level??

Thanks

Coop123
 
Upvote 0
Found this for you
VBA Code:
Sub Macro2()

Dim strDefaultPath As String
Dim strDefaultName As String
Dim strDialogBoxName As String
Dim strFilePath As String

'//Change the following 3 variables to suit your needs.
strDefaultPath = "J:\Material Type\Report files"
strDefaultName = ""
strDialogBoxName = "Your choice:"

strFilePath = Application.GetSaveAsFilename(strDefaultPath & _
    strDefaultName & ".xlsm", "Workbook (*.xlsm), *.xlsm", , strDialogBoxName)

    If strFilePath = "False" Then
        Exit Sub
    Else
        ActiveWorkbook.SaveAs Filename:=strFilePath
    End If

End Sub
 
Upvote 0
Thank you. That was exactly what I wanted.

Everything is now working perfectly.

Thanks again

Coop123
 
Upvote 0

Forum statistics

Threads
1,215,518
Messages
6,125,292
Members
449,218
Latest member
Excel Master

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