H
haakon
I have a bunch of textfiles that I import to excel with some macros I
have recorded/written. There are 4 different types of textfiles, so
the macro reads the content of cell M1, e.g. "TYPE 1", and then
imports the textfile with the appropriate formatting for textfile type
1. This kind of works, but it would be much more clever if I could
make the following work: Line 58 of each textfile is specific to the
type of textfile. I therefore need to make Excel read the contents of
line 58 before importing the textfile, and assign the contents to a
variable. I could use this variable to define the necessary
formatting. So something like this:
read line 58 of textfile.txt -> assign the contents of the line to
variable TYPE
Select case TYPE
case "this is a type1 file"
formatoptions 1
case "this is a type2 file"
formatoptions 2
..
case else
msgbox "unrecognized file"
End Select
So long story short: How do I say in VBA code that the contents of
line 58 in a specified file is to be assigned to a variable?
have recorded/written. There are 4 different types of textfiles, so
the macro reads the content of cell M1, e.g. "TYPE 1", and then
imports the textfile with the appropriate formatting for textfile type
1. This kind of works, but it would be much more clever if I could
make the following work: Line 58 of each textfile is specific to the
type of textfile. I therefore need to make Excel read the contents of
line 58 before importing the textfile, and assign the contents to a
variable. I could use this variable to define the necessary
formatting. So something like this:
read line 58 of textfile.txt -> assign the contents of the line to
variable TYPE
Select case TYPE
case "this is a type1 file"
formatoptions 1
case "this is a type2 file"
formatoptions 2
..
case else
msgbox "unrecognized file"
End Select
So long story short: How do I say in VBA code that the contents of
line 58 in a specified file is to be assigned to a variable?