I am stuck. It still gives me error 3125 is not a valid name.
code looks like this now:
Code:
Private Sub Command40_Click()
Dim oExcel As New Excel.Application
Dim oWb As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim fileName As StringoExcel.Workbooks.Open (CurrentProject.Path & "\" & "book1.xls")
oExcel.Visible = True
Set oWb = oExcel.Workbooks(1)
Set oSheet = oExcel.ActiveWorkbook.Worksheets("sheet1")
oSheet.Unprotect ("qwerty")fileName = "C:\Users\Desktop\Database\Book1.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "jj", fileName, True
Set oSheet = Nothing
Set oWb = Nothing
Set oExcel = Nothing
End Sub
It transfers one simple query or simple tables to excel. But does not work on the crosstab query I want to transfer.
Access also starts running the query. It only brakes at
Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "jj", fileName, True