So in my c drive I made a folder named digital and within digital I made another folder named 05A414295RUK. When I run the code I get a box to choose a folder. The only folders I see are those within digital. I choose the folder 05A414295RUK press the button and the Excel file is saved in the folder named 05A414295RUK and the name of the file is 05A414295RUK.xlsm. If I misunderstood something you said, let me know, it's probably an easy fix.
I made a couple of other folders in digital and ran the code against those folders and it seemed to work fine.
I haven't done any coding like this so I enjoyed it and learned something.
Thanks for the opportunity.
Option Explicit
Sub AutoSave()
Dim fdp As FileDialog
Dim sItem As String
Dim strPath As String
Dim strFullPath As String
Dim c As Long
strPath = "C:\Digital\"
Set fdp = Application.FileDialog(msoFileDialogFolderPicker)
With fdp
.ButtonName = "Choose Folder and Click"
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = strPath
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
c = InStr(1, StrReverse(sItem), "\")
strFullPath = sItem & Right(sItem, c) & ".xlsm"
ThisWorkbook.SaveAs strFullPath, FileFormat:=xlOpenXMLWorkbookMacroEnabled
NextCode:
Set fdp = Nothing
End Sub
Bookmarks