Re: Text file I/O in VBA



John,
I am trying to do it the way you described above, but it never gives me an
option to save the specification. On the advanced tab, the save and specs..
button are always disabled?

Steve

"John Nurick" wrote:

When I wrote

trim the header lines and import it as a fixed-width file

I meant that you should first use the TrimFileHeader() function to
dispose of the header lines and get you an ordinary fixed-width text
file. Once you have that, you can use DoCmd.TransferText with an import
specification to import the file in the usual way.

If you don't know what that is:
1) Import the file manually (File|Get External Data|Import)
2) When you get to the text import wizard, make all the necessary
settings, click the Advanced button, make more adjustment if needed, and
save the result as an import/export specification.
3) Subsequently, to import the file (or files with the same structure)
under program control, use DoCmd.TransferText and pass the name of the
specification you saved.

On Fri, 25 Aug 2006 05:20:02 -0700, SteveInBeloit
<SteveInBeloit@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

the normal commas in the text are killing me. it splits them at the commas
like in $1,333.22.

It must need to know it is a fixed width. I didn't put anything on it to
tell it was should be comma separated, do I have to put something on it to
tell it it is fixed width?

Thanks very much
Steve

"John Nurick" wrote:

In that case, trim the header lines and import it as a fixed-width file.

On Thu, 24 Aug 2006 14:46:02 -0700, SteveInBeloit
<SteveInBeloit@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

John,
Nope, no commas, just looks like a report.
Steve

"John Nurick" wrote:

Hi Steve,

If the file is ordinary comma-separated text once you're past the first
four lines, you can use the TrimFileHeader() function at
http://www.j.nurick.dial.pipex.com/Code/index.htm



On Thu, 24 Aug 2006 13:20:25 -0700, SteveInBeloit
<SteveInBeloit@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Hello,
Kind of struggling here. I need to read in a text file that contains prices
from a vendor. It is a formatted text file, so the first line is a heading,
second line spaces, third line heading, fourth line all dashes, then the
good stuff.
Each of the next lines have upc, date, old price, new price...

From reading, I thought this may work. Really hokey how I did the first
four lines, but don't know what to do:

Open "c:\pfms.txt" For Input As #1
Input #1, srtLine
Input #1, strLIne
Input #1, strLIne
Input #1, strLIne

Do While Not EOF(1)
Input #1, str1, str2, str3, str4, str5
Loop
Close #1

I have acouple of problems. When it starts reading the fifth line on, I get
the entire line in each variable. I don't know how to tell it they are
separate fields. It is formatted like a normal report, not csv.
Second, it reads passed the end of file.
Open to how to do this, or better options.

Thanks

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

.


Loading