>>205 サンプルを作ってみました。 '---------Sample----------- Sub Data_Import() Dim cn As New ADODB.Connection, rs As New ADODB.Recordset Dim ShinkiFullName As String, ShinkiFile As String Dim wb As Workbook, ws As Worksheet, c As Integer
'新規ブックのSheet1にデータを写す Set wb = Workbooks(ShinkiFile): Set ws = wb.Worksheets("Sheet1") With ws For c = 0 To rs.Fields.Count - 1 'フィールド名をA1から横にコピー .Cells(1, c + 1).value = rs.Fields(c).Name Next c .Cells(2, 1).CopyFromRecordset rs 'レコードをA2以降にコピー End With
'接続終了 rs.Close: Set rs = Nothing cn.Close: Set cn = Nothing