How to write a macro to import text file?

  • Thread starter Thread starter tomaski
  • Start date Start date
T

tomaski

Hi All,

I have a bunch of text in an Access table field named "QDATA". The data
looks like this:
-------------------------------------------------------------------------------------------
<QUESTION DESCRIPTION=""174 - Text 1........."" TOPIC=""topic""
ID=""00666666"" STATUS=""Normal"" TYPE=""text/html"" >
<TAG NAME=""Difficulty"">Master</TAG>
<CONTENT TYPE=""text/html"" >
<![CDATA[<B>What is the color of your eyes?</B><BR><BR>
]]></CONTENT>
<CHOICE ID=""0"">
<CONTENT TYPE=""text/html""><![CDATA[Brown]]></CONTENT>
</CHOICE>
<CHOICE ID=""1"">
<CONTENT TYPE=""text/html""><![CDATA[Red]]></CONTENT>
</CHOICE>
<CHOICE ID=""2"">
<CONTENT TYPE=""text/html""><![CDATA[Blue]]></CONTENT>
</CHOICE>
<CHOICE ID=""3"">
<CONTENT TYPE=""text/html""><![CDATA[Yellow]]></CONTENT>
-----------------------------------------------------------------------------------

I want to break this field of data into another table with the following
fields:
QUESTION DESCRIPTION (in this case data is "What is the color of your eyes?"
DIFFICULITY (in this case data is "Master")
CHOICE 0 (in this case is "Brown")
CHOICE 1 (in this case is "Red")
CHOICE 2 (in this case is "Blue")
CHOICE 3 (in this case is "Yellow")

The text is downloaded from a web template and not seperated by anything (it
is everything together). Should I use macro or is there an easier way to
solve this? Any help will be appreciated.

Thanks.
 
You can write a VBA procedure that will read and parse the data in the text
file, and that then will write the data into a table the way you want to
store it.
 
Back
Top