| | |
How to write files to an Excel application
![]() |
•
•
Join Date: May 2004
Posts: 40
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by GB4mytime
Can anyone tell me how to write files or output to an excel file with tabs etc.
Thanks,
GB4
quite easily. Even put a Total at the end of one column (only number column).
It does, however require the user to format the columns as to widths, etc. so
I would also be interested in any info about formatting the columns.
•
•
Join Date: Jul 2004
Posts: 2
Reputation:
Solved Threads: 0
Thnnks for your reply. If you had a little more information or details on how to do this it would be much appreciated
Thanks
Thanks
•
•
•
•
Originally Posted by Buff
i've been able to write a comma-delimited file for use as an excel spreadsheet
quite easily. Even put a Total at the end of one column (only number column).
It does, however require the user to format the columns as to widths, etc. so
I would also be interested in any info about formatting the columns.
•
•
•
•
Originally Posted by Buff
i've been able to write a comma-delimited file for use as an excel spreadsheet
quite easily. Even put a Total at the end of one column (only number column).
It does, however require the user to format the columns as to widths, etc. so
I would also be interested in any info about formatting the columns.
Here's a code snippet that writes the contents of an ADO recordset to a Excel file, you'll need to reference an Excel library in your project for it to work. Basically you need to learn about the Excel object model, try looking in your MSDN documentation.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'******************************************************************************* ' excelPrintRecordSet(Sub) ' ' PARAMETERS: ' ' ' RETURN VALUE: ' ' ' DESCRIPTION: ' Test function that will print out all the records from a recordset in Excel. '******************************************************************************* Public Sub excelPrintRecordSet(rstTmp As ADODB.Recordset) Dim appExcel As Excel.Application Dim wbkReport As Excel.Workbook Dim wksReport As Excel.Worksheet Dim intField As Integer, intRow As Integer Const PROCEDURE_NAME As String = "excelPrintRecordSet" On Error GoTo errorHandler Set appExcel = New Excel.Application appExcel.Visible = True Set wbkReport = appExcel.Workbooks.Add 'wbkReportame = "Kilometer Report" Set wksReport = wbkReport.Worksheets(1) If rstTmp.EOF <> True Then rstTmp.MoveFirst intRow = 1 Do For intField = 0 To rstTmp.Fields.Count - 1 wksReport.Cells(intRow, intField + 1) = rstTmp.Fields(intField).Name & "=" & rstTmp.Fields(intField).Value Next intField rstTmp.MoveNext intRow = intRow + 1 Loop Until rstTmp.EOF = True End If Exit Sub errorHandler: frmErrorHandler.errorForm MODULE_NAME, PROCEDURE_NAME Err.Clear End Sub
![]() |
Similar Threads
- to convert Snap shot(.snp) files to Excel - Microsoft Windows 2000 (Windows Software)
- Write Data Into Excel Sheet (Pascal and Delphi)
- read/write files using visual studio 2009 (VB.NET)
- How to handle multiple files, to Excel (VB.NET)
- Reconnecting to the existing excel application (C#)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Taking cmmd prompt data into Vb
- Next Thread: Users Saving Games?
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





