استخدم هذا الكود .......
Dim strDirectoryPath As String
strDirectoryPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & "sample"
If Dir(strDirectoryPath, vbDirectory) = "" Then MkDir strDirectoryPath
Output_Path = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & "sample" & "\" & Format(Date, "dd-mm-yyyy") & ".xlsx"
DoCmd.OutputTo acOutputQuery, "q1", "ExcelWorkbook(*.xlsx)", Output_Path, False, "", , acExportQualityPrint
MsgBox "تمت عملية انشاء المجلد باسم Sample بنجاح مع تصدير الملف", vbInformation, " مبروك "