Q: VBAでエクセルを利用するには? A: 次のような関数を使ってみてはどうでしょうか。
Punlic Function Excel()
'************************************
'エクセルのセルに入れるデータの取得
'************************************
Dim i
i=1
Dim Rs As DAO.Recordset
Set Rs = CurrentDb.OpenRecordset("Q_DATA", dbOpenSnapshot)
While Rs.EOF = False
If IsNull(Rs("FieldName01")) Then
D01(i) = ""
Else
D01(i) = Rs("FieldName01")
End If
i = i + 1
Rs.MoveNext
Wend
Rs.Close
'************************************
'エクセルオブジェクトの作成
'************************************
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.workbooks.Open("C:\Book1.xls")
Set oSheet = oBook.worksheets("Sheet1")
'*************************************
'セル、行=1、列=2に値を代入
'*************************************
oSheet.cells(1, 2) = D01(i)
'*************************************
'オブジェクトの解放
'*************************************
oExcel.Visible = True
Set oSheet = Nothing
Set oBook = Nothing
Set oExcel = Nothing
End Function
Q: Access2003 RunTimeありますか?