F
FGM
windows 2000 excel / access 2002
Trying to send several groups of data to excel. Want to be able to create
and name the worksheets from the program and put the data on the worksheet.
I have been able to send one field but not all the fields.. I think I do not
know how to work the objXLRange.FormulaArray = Array(varResults).
Does anyone know where I can read more about transfer data from access to
excel through vba? Thanks
code follows:
Public Sub TransferSim()
Dim objXLApp As Excel.Application
Dim objXLBook As Excel.Workbook
Dim objQuerySheet As Excel.Worksheet
Dim objResultsSheet As Excel.Worksheet
Dim objXLRange As Excel.Range
Dim db As DAO.Database
Dim strSQL As String
Dim rst1 As Recordset
Dim varResults As Variant
Dim intCount As Integer
Set objXLBook = Workbooks.Add("P:\Templates\Braslau XLT\Simulation.xlt")
Set objXLApp = objXLBook.Parent
objXLBook.Worksheets.Add
objXLBook.ActiveSheet.Name = "test"
objXLApp.Visible = True
objXLBook.Windows(1).Visible = True
' objXLBook.Sheets.Add
' objXLBook.ActiveSheet.Name = "test"
Set db = CurrentDb
' strSQL = "SELECT
ProjectID,SourceNumber,SourceName,ReceiverNumber,RecordNumber,LapDur,DurSec
FROM tblSourceAnswers Where ProjectID = 22 ORDER BY ReceiverNumber"
strSQL = "SELECT ProjectID,ReceiverNumber,SL,SL_DurSec,SPL FROM
qrySimulationC Where ProjectID = 22 ORDER BY ReceiverNumber"
Set rst1 = db.OpenRecordset(strSQL, dbOpenDynaset)
intCount = rst1.RecordCount
'Set qdfLost = dbThis.QueryDefs("qryLostCount")
varResults = rst1.GetRows(intCount)
rst1.Close
db.Close
Set objXLRange = objXLBook.ActiveSheet. _
Range("A2:E" & 1 + intCount)
objXLRange.FormulaArray = Array(varResults)
Exit Sub
Trying to send several groups of data to excel. Want to be able to create
and name the worksheets from the program and put the data on the worksheet.
I have been able to send one field but not all the fields.. I think I do not
know how to work the objXLRange.FormulaArray = Array(varResults).
Does anyone know where I can read more about transfer data from access to
excel through vba? Thanks
code follows:
Public Sub TransferSim()
Dim objXLApp As Excel.Application
Dim objXLBook As Excel.Workbook
Dim objQuerySheet As Excel.Worksheet
Dim objResultsSheet As Excel.Worksheet
Dim objXLRange As Excel.Range
Dim db As DAO.Database
Dim strSQL As String
Dim rst1 As Recordset
Dim varResults As Variant
Dim intCount As Integer
Set objXLBook = Workbooks.Add("P:\Templates\Braslau XLT\Simulation.xlt")
Set objXLApp = objXLBook.Parent
objXLBook.Worksheets.Add
objXLBook.ActiveSheet.Name = "test"
objXLApp.Visible = True
objXLBook.Windows(1).Visible = True
' objXLBook.Sheets.Add
' objXLBook.ActiveSheet.Name = "test"
Set db = CurrentDb
' strSQL = "SELECT
ProjectID,SourceNumber,SourceName,ReceiverNumber,RecordNumber,LapDur,DurSec
FROM tblSourceAnswers Where ProjectID = 22 ORDER BY ReceiverNumber"
strSQL = "SELECT ProjectID,ReceiverNumber,SL,SL_DurSec,SPL FROM
qrySimulationC Where ProjectID = 22 ORDER BY ReceiverNumber"
Set rst1 = db.OpenRecordset(strSQL, dbOpenDynaset)
intCount = rst1.RecordCount
'Set qdfLost = dbThis.QueryDefs("qryLostCount")
varResults = rst1.GetRows(intCount)
rst1.Close
db.Close
Set objXLRange = objXLBook.ActiveSheet. _
Range("A2:E" & 1 + intCount)
objXLRange.FormulaArray = Array(varResults)
Exit Sub