J
Jarryd
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
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