Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
This is an excerpt of some code I have been working on: -------start------------ FileToOpen = Application.GetOpenFilename If FileToOpen < False Then 'Set path path = Left(FileToOpen, InStrRev(FileToOpen, "\")) 'Open connection to file cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path & ";Extended Properties='text;HDR=NO;FMT=Delimited'" 'Set file file = Right(FileToOpen, Len(FileToOpen) - InStrRev(FileToOpen, "\")) 'Open recordset with Earnie data rsEarnie.Open "Select * From " + file, cn, adOpenStatic, adLockReadOnly, adCmdText -------end------------ It works fine when the source file has an extension of "txt", but I want it to work regardless of the extension. The file that will be selected will be produced by our payroll package and is created as payroll.001 or payroll.002. Rather than ask users to rename the file with a "txt" extension, is there a way to read the data in the file as text without the file explicitly being named as a text file? I have tried adCmdUnknown and all the others but they don't work. I get: "Run-time error'-2147217911 (80040e09': Automation error" Any ideas? TIA Jarryd |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Read of excel spreadsheet with ADO recordset | Excel Programming | |||
help with macro to read and sort data from multiple text files | Excel Programming | |||
ADO recordset closed, cannot read | Excel Programming | |||
How to read multiple text files into excel? | Excel Programming | |||
Read/Write data to/from text files from a spreadsheet. | Excel Programming |