View Single Post
  #2 (permalink)  
Old 12-08-03, 08:30
HomerBoo HomerBoo is offline
Registered User
 
Join Date: Sep 2003
Location: T.O.
Posts: 326
I'm not sure if 'Excel' in your code is a variable or not. Here's how I address Excel's hierarchy (I have tried a few methods, but this seems to work best for my uses):

Dim xlObject As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlObject = New Excel.Application
Set xlWB = xlObject.Workbooks.Add
Set xlSheet = xlWB.ActiveSheet

xlSheet.Range("A1").Value = "ValueA"

etc.

BTW, if I'm reading your code correctly, you are outputting a recordset into Excel. If you're using the Excel 10.0 Object Lib (and possibly 9.0), the Range object exposes a .CopyFromRecordset method that will do that for you. All you would need to do is create the headings.
__________________
All code ADO/ADOX unless otherwise specified.
Mike.
Reply With Quote