:)
I want to export MS Access 2000 records to Excel sheet from vb6.0? How to do it?
thanx in advance...
Printable View
:)
I want to export MS Access 2000 records to Excel sheet from vb6.0? How to do it?
thanx in advance...
I found this code and have used it in one of my apps. HTH :)
VB Code:
Public Sub CopyTableData() fldCount = rsSelectedTrades.Fields.Count recArray = rsSelectedTrades.GetRows recCount = UBound(recArray, 2) + 1 objExcel.Cells(34, 80).Resize(recCount, fldCount).Value = TransposeDim(recArray) End Sub Function TransposeDim(v As Variant) As Variant ' Custom Function to Transpose a 0-based array (v) Dim X As Long, Y As Long, Xupper As Long, Yupper As Long Dim tempArray As Variant Xupper = UBound(v, 2) Yupper = UBound(v, 1) ReDim tempArray(Xupper, Yupper) For X = 0 To Xupper For Y = 0 To Yupper tempArray(X, Y) = v(Y, X) Next Y Next X TransposeDim = tempArray End Function
I myself have been creating a report generator exporting info from SQl Server stored procs to Excel.
VB Code:
'populate a recordset recExport with the info from Access 'Set up column headers Dim objFiled As Field For Each objFiled In recExport.Fields With m_objSheet.Cells(1, intFieldCounter) .Value = Replace$(objFiled.Name, "_", Space(1)) .Font.Bold = True .Font.Size = 11 .Interior.Color = &H808080 End With 'objSheet.Cells(1, intFieldCounter) intFieldCounter = intFieldCounter + 1 Next 'objFiled 'Export the recordset to the worksheet m_objSheet.Range("a2").CopyFromRecordset recExport m_objSheet.Columns.AutoFit m_objSheet.Activate m_objSheet.Rows(2).Select m_objApp.ActiveWindow.FreezePanes = True
sorry in a rush but I hope this helps.
:wave: :thumb: :wave: