Sub ztest()
Dim xlApp As Object, xlWb As Object
Const QryName As String = "tblTeams"
DoCmd.OutputTo acOutputTable, QryName, acFormatXLS, "c:\qw.xls"
Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Open("c:\qw.xls")
With xlWb
.Worksheets(QryName).Name = "test"
.Save
.Close
End With
Set xlWb = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
|