Exporting Access to Macro Enabled Excel

时间:2016-07-11 21:09:13

标签: ms-access ms-access-2013

does anyone know what is the appropriate excel number to use for macro enabled worksheets?

Specifically: I'm trying to export a table from access to xlsm using this function. Is there a different numeration for the macro enabled workbook?

acSpreadsheetTypeExcel12Xml

1 个答案:

答案 0 :(得分:2)

If you want to export data to excel template with formatting and mcroses, do not use DoCmd.TransferSpreadsheet method, it just creates Excel file without macroses. Use CopyFromRecordset method of Range object (MS Excel library) instead:

    Set xlApp = CreateObject("Excel.Application")
    Set xlWork = xlApp.Workbooks.Open(strFileName)
    Set xlSheet = xlWork.Sheets(strWSName)
    xlSheet.Range("A3").CopyFromRecordset rsExportResults