Hi
I have the following setup to export some queries to Excel files. It on a loop and exports each one in turn.
This has been working fine for month, then all of a sudden this morning it stops working, saying it's not a valid path, even though if I debug.print the path copy and paste it, the location opens, any ideas?
I have the following setup to export some queries to Excel files. It on a loop and exports each one in turn.
This has been working fine for month, then all of a sudden this morning it stops working, saying it's not a valid path, even though if I debug.print the path copy and paste it, the location opens, any ideas?
Code:
'Set year path to save file
Path1 = "S:\Obox Techincal Services\Daily Checks\" & Format(DateToCheck, "yyyy") & "\" & Format(DateToCheck, "mmmm")
If Dir(Path1, vbDirectory) = "" Then
sPath = Path1
CreateDirectory (sPath)
End If
'Daily check files
Set rsExports = db.OpenRecordset("SELECT * FROM tblReports WHERE OboxChecks = 1 AND isLive = 1 ORDER BY ID ASC")
rsExports.MoveLast
rsExports.MoveFirst
Do Until rsExports.EOF
Filename = Path1 & "\" & Format(DateToCheck, "dd-mm-yyyy") & rsExports("SaveName")
' Filename = Filename & rsExports("Fileformat")
' DoCmd.TransferSpreadsheet acExport, , rsExports("RptName"), Filename '& ".xlsx"
DoCmd.OutputTo acOutputQuery, rsExports("RptName"), "ExcelWorkbook(*.xlsx)", Filename & ".xlsx", False, "", , acExportQualityPrint
Filename = Filename & rsExports("Fileformat")
Qry = rsExports("SheetName")
Conditional = 0
Call FormatExport(Filename, Qry, Conditional)
rsExports.MoveNext
Loop