Why does the code below work in some databases and not others? Even from week to week in the same database?
Option Compare Database
Option Explicit
Sub OUTPT()
Dim qdftemp As QueryDef
Dim a As String
For Each qdftemp In CurrentDb.QueryDefs
a = qdftemp.Name
DoCmd.OutputTo acQuery, a, “MicrosoftExcel(*.xls)”, _
“C:My DocumentsTESTSTORES” & qdftemp.Name & “.xls”, False, “”
Debug.Print qdftemp.Name
Next
End Sub