OpenText question

D

dlevine54

have an Access database from which I create a CSV file. Now they want an
XLS spreadsheet also. Since I already have the CSV I want to use that to
create the spreadsheet but can't. I'm using Office 2003. My code is below.

Dim oExcel As Object
Dim oBook As Excel.Workbook
Dim oBooks As Excel.Workbooks
Dim oSheets As Excel.Sheets
Dim oSheet As Excel.Worksheet

' Open the excel spreedsheet
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add()
Set oBook = oExcel.Workbooks.OpenText(CSV_doc_name, StartRow:=3, _
DataType:=Excel.XlTextParsingType.xlDelimited, Comma:=True)
oBook.Close
Set oExcel = Nothing

I keep getting an 'Object is required' error on the OpenText line. Can
someone help me understand why?
 
O

OfficeDev18 via AccessMonster.com

Why re-invent the wheel? All you need to do is use the DoCmd.TransferText and
DoCmd.TransferSpreadsheet statements. See the TransferX methods in the Help
for details and usage.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top