简体   繁体   English

Excel VBA数据导出

[英]Excel VBA Data Export

Here is the code I have written to export data from access to excel but can not see any records. 这是我编写的用于从excel导出数据但看不到任何记录的代码。

Sub copyFromRecordset()

    Set conn = New ADODB.Connection
    Set wipData = New ADODB.Recordset

    conn.ConnectionString = conStr
    conn.Open

    With wipData
        .ActiveConnection = conn
        .Source = "WipBin"
        .LockType = adLockReadOnly
        .CursorType = adOpenForwardOnly
        .Open
    End With

    Worksheets.Add
    Range("A2").copyFromRecordset wipData

    wipData.Close
    conn.Close

End Sub

please advice 请指教

Why not Simply use the DoCmd.TransferSpreadsheet method 为什么DoCmd.TransferSpreadsheet使用DoCmd.TransferSpreadsheet方法

DoCmd.TransferSpreadsheet acExport, , "TABLE name", "filelocation"

https://msdn.microsoft.com/en-us/vba/access-vba/articles/acspreadsheettype-enumeration-access https://msdn.microsoft.com/zh-CN/vba/access-vba/articles/acspreadsheettype-enumeration-access

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM