Wow. I'm just a regular code thief. I stole this from the VBPro mailing
list seconds ago for a VBPro database mailing list question, and here it is
again (still in my clipboard buffer). This is an example of using OLE
Automation with Excel:
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
nWorkSheetCtr = 0
For i = 1 To 4
nWorkSheetCtr = nWorkSheetCtr + 1
Set xlSheet = xlBook.Worksheets(nWorkSheetCtr)
xlSheet.Cells(1, 1) = "TEST REPORT SYSTEM"
xlSheet.Cells(2, 1) = "SAMPLE REPORT"
xlSheet.Cells(3, 1) = "Run Date/Time: " & strDateTime
xlSheet.Cells(6, 1) = "NAME" & Trim(Str(i))
xlSheet.Cells(6, 2) = "POSITION"
cFileName = "c:\temp\test.xls"
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
xlShell = Shell("C:\Program Files\Microsoft Office\Office\Excel.exe " +
> -----Original Message-----
> From: rgallegos@v... [mailto:rgallegos@v...]
> Sent: Monday, May 28, 2001 4:04 PM
> To: VB_Howto
> Subject: [vb_howto] Export to predefine excel file
> I know how to export data to excel directly.
> But I need export to predefine excel file (with headers, vertical and
> horizontal lines, colors).
> My original data are just in a one column and several rows.
> What it?s better o more easily to use?
> Export directly my data to predefine excel file?, or Use my first excel
> file to export to a predefine file ?
> But I don?t how make this? Somebody have an idea, some piece of code ?
> Your help it?s very appreciate for me.
> Thanks in advance