Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transfer Query Results to Excel (Office 365)

Status
Not open for further replies.

MacroAlan

Programmer
Dec 4, 2006
134
0
0
US
Been a very long time since I tried to do this. Every time I try to open the exported workbook, it is corrupted. Are the spreadsheet types changed in Office 365?

Code:
Private Sub cmdMailPrinter_Click()
On Error GoTo cmdMailPrinter_Click_Err

   ' DoCmd.OpenQuery "qryMailing4Printer", acViewNormal, acEdit
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "qryMailing4Printer", _
        "C:\USERS\" & Environ("USERNAME") & "\Desktop\Printer_" & _
        Format(Now(), "yyyymmdd") & ".xlsx", True
    

cmdMailPrinter_Click_Exit:
    MsgBox "File at C:\USERS\" & Environ("USERNAME") & "\Desktop\Printer_" & _
        Format(Now(), "yyyymmdd")
    Exit Sub

cmdMailPrinter_Click_Err:
    MsgBox Error$
    Resume cmdMailPrinter_Click_Exit

End Sub


Alan
[smurf]
 
Never mind! Figured it out


Code:
    CurPath = "C:\USERS\" & Environ("USERNAME") & "\Desktop\GPS_Printer_Export_" & Format(Now(), "yyyymmdd") & ".xlsb"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryMailing4Printer", CurPath, -1


Alan
[smurf]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top