簡體   English   中英

如何從 Word VBA 到 excel 表中獲取記錄集數據?

[英]How to get the recordset data from Word VBA to excel sheet?

我是 VBA 的新手,為了滿足部分要求,我需要使用 Word 宏從 SQL 表到 Excel 表中獲取數據。 我嘗試過了

  1. 使用 ADODB 連接連接到 SQL 並為記錄集創建和設置 object
  2. I have created and set the necessary excel objects like Excel.Application, Excel.WorkBook and Excel.WorkSheet But I'm stuck with how to get the data from recordset into Excel sheet

這是微軟網站上的指南: https://learn.microsoft.com/en-us/previous-versions/office/troubleshoot/office-developer/transfer-excel-data-from-ado-recordset

這部分可能是您需要的關鍵部分(但您也可能需要之前的部分來處理日期值和其他更復雜的數據類型:

' Transpose and Copy the array to the worksheet,
        ' starting in cell A2
        xlWs.Cells(2, 1).Resize(recCount, fldCount).Value = _
            TransposeDim(recArray)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM