Re: How to get data from txt file into table of word template thro



This is a big topic, and it's not at all obvious what you're asking. By
definition, XML is easiest to parse because it's structured specifically to
be parsable; but if it's XML why bother with VBA? -- why not let Word or
Excel parse it for you? TXT and DOC files are parsable to the extent that
they're structured (they are, at least, easy to read). You can't do anything
with a PDF without converting it to something else first (which isn't always
possible).

You seem to be asking two questions: 1) how to parse a source file, and 2)
how to use VBA to populate a Word document. These are entirely separate
issues. Stay with the literature.




"Sam" <Sam@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AC441C83-7121-4151-ADC9-43BCA1E1181D@xxxxxxxxxxxxxxxx
HI, Jezebel:

Actually,I am new user to VBA programming. Now i am reading literature in
this field. I am thinking about the best way to load data into table of
Word.
I haven't done any test in pratical VBA progarmming. IF the data source
file
can be in PDF, DOC, TXT or XML format, which one is the best one to parse
using VBA? Do you have some experience on this issue? And could you
recommend
some relevant material to me?

Thanks In advance!

Regards

Sam

"Jezebel" wrote:

It's like asking "How do I drive from Paris to Moscow, where do I turn
left?"

There's a whole heap of commands for parsing strings. You could use
Split()
to divide the lines up by the commas. Or maybe just dump the lot into
Excel
and use the Text-to-columns function.

As before: what have you tried so far, and what went wrong?




"sam" <shang.gao.uu@xxxxxxxxx> wrote in message
news:1145523468.960035.218380@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

Thank you for answer!

As the data info in the txt.file is not in standard table format, How
can I extract the exactly data info from the txt.file.

The data format in txt file is something like this:

Sam, (27, US, +1-513-1389, sam@xxxxxxxxx)
Lisa: (UK, 28, +44-318900, Lisa@xxxxxxxxx)

the table in word template has two column, and it gives out the name
info:
Name Telephone
Sam
Lisa
...

It is possible to extract info from TXT.file and insert into table in
word using VBA. Could you give me some coding info for this sample?

Best Regards

Sam






.



Relevant Pages

  • Re: How to get data from txt file into table of word template thro
    ... Word and XML: this is well covered in Word's own documentation. ... There's no way to answer the question about whether VBA is the best solution ... For the XML data source file, you said Word can parse it by itself. ... Excel parse it for you? ...
    (microsoft.public.word.vba.general)
  • Re: How to get data from txt file into table of word template thro
    ... For the XML data source file, you said Word can parse it by itself. ... but if it's XML why bother with VBA? ... As the data info in the txt.file is not in standard table format, ...
    (microsoft.public.word.vba.general)
  • ISO: techniques or examples of visualizing xml
    ... I've a collection of information which I received in XML format. ... data in a tabular fashion, with some hopes of being able to click on a ... It seems to me that the xml should be pretty simple to parse - but I've never ...
    (comp.lang.tcl)
  • Re: ISO: techniques or examples of visualizing xml
    ... > I've a collection of information which I received in XML format. ... > It seems to me that the xml should be pretty simple to parse - but I've never ... You could just use one of the XML extensions to parse the file directly ...
    (comp.lang.tcl)
  • Re: How to get data from txt file into table of word template thro
    ... I need first find info in XML file(all the info can be found in XML ... There's no way to answer the question about whether VBA is the best solution ... For the XML data source file, you said Word can parse it by itself. ...
    (microsoft.public.word.vba.general)