+ Post New Thread
Results 1 to 10 of 10
Scripts Thread, Autoit script to open word file, read line by line, split words in Coding and Web Development; I have a word file with text something like this: Name:: Xyz Address1:: Street 1 Pin:: 48429 I need to ...
  1. #1

    Join Date
    Apr 2009
    Posts
    2
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Autoit script to open word file, read line by line, split words

    I have a word file with text something like this:

    Name:: Xyz
    Address1:: Street 1
    Pin:: 48429

    I need to open this file read line by line. Split line on '::'. Then get the splitted elements separately.

    Any help on this???

  2. #2
    amfony's Avatar
    Join Date
    Jul 2007
    Location
    Sydney
    Posts
    161
    Thank Post
    29
    Thanked 13 Times in 13 Posts
    Rep Power
    17
    define "help" - what do you have so far? If you have nothing then why do you require autoIT?

  3. #3
    dwhyte85's Avatar
    Join Date
    Mar 2009
    Location
    Berkshire
    Posts
    1,232
    Thank Post
    162
    Thanked 151 Times in 136 Posts
    Rep Power
    104
    Why AutoIT, convert the doc to a text file and use VBS, tonnes of good info available on net on how to open a text file, how to find the position of a string and how to break it into separate chunks, lots & lots!

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,995
    Thank Post
    3,539
    Thanked 1,111 Times in 1,017 Posts
    Rep Power
    374
    Quote Originally Posted by dwhyte85 View Post
    Why AutoIT, convert the doc to a text file and use VBS, tonnes of good info available on net on how to open a text file, how to find the position of a string and how to break it into separate chunks, lots & lots!
    agreed

    If you do that I can help with the vbs side

  5. Thanks to mac_shinobi from:

    autoit (9th April 2009)

  6. #5

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,158
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Open the file in Excel, tell it that it's delimited and the delimiter is :: or whatever. You'll then get nice tidy columns which you can do with what you please :-)

  7. #6
    dwhyte85's Avatar
    Join Date
    Mar 2009
    Location
    Berkshire
    Posts
    1,232
    Thank Post
    162
    Thanked 151 Times in 136 Posts
    Rep Power
    104
    Very good idea but depends on what he wants to do with it after, but CSV is the simplest suggestion!

  8. #7

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,158
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Quote Originally Posted by dwhyte85 View Post
    Very good idea but depends on what he wants to do with it after, but CSV is the simplest suggestion!
    Not sure what you're commenting on but if he hasn't got a CSV file but has one with an odd layout and colon delimiters then he needs some way of getting that to CSV or something else which can be processed.

    This is the kind of thing where the route you take depends on how often you need to do it. For a one off, you'll probably put in less effort than if you're doing it multiple times.

    if you're familiar with grep, sed and the other Unix text processing commands then you could probably do it all with them!

  9. Thanks to srochford from:

    autoit (9th April 2009)

  10. #8
    dwhyte85's Avatar
    Join Date
    Mar 2009
    Location
    Berkshire
    Posts
    1,232
    Thank Post
    162
    Thanked 151 Times in 136 Posts
    Rep Power
    104
    Import data in Excel and use the :: as the delimiter and resave as CSV or just export the data/manipulate as needed with Excel... not rocket science... horses for courses... but, why reinvent the wheel?

    As it's currently a word doc he'd need to get it into a plain text format then onto a unix box/open from a unix machine, i think my way might be a bit easier in this scenario ;-)
    Last edited by dwhyte85; 8th April 2009 at 11:10 PM.

  11. Thanks to dwhyte85 from:

    autoit (9th April 2009)

  12. #9

    Join Date
    Apr 2009
    Posts
    2
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Thanks all..
    i'm a newbie to scripting world..

    The info contained in the file will be used for further processing. The file may be word or text.

    I have idea with opening the word file:
    $oWordApp = _WordCreate(@ScriptDir & "\File1.doc")
    $oDoc = _WordDocGetCollection($oWordApp, 1)

    I want to know if there is any commands to read line by line from word file and split lines on certain characters.

    Else let me know if anything i can do with text file only.

    Thanks in advance...

  13. #10

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,995
    Thank Post
    3,539
    Thanked 1,111 Times in 1,017 Posts
    Rep Power
    374
    vbscript
    Code:
      Set Word = CreateObject("Word.Application")
        Word.Visible = TRUE
        Word.Documents.Open("C:\My Path\myfile.doc")
    Then have a macro that launches when its opened to check the data in the word document and split it up and put it how you want into a text file or do whatever you want with it ?

    Description of behaviors of AutoExec and AutoOpen macros in Word

    Then once the macro has done everything you want just save it and quit word and that should be it ?

    Short of that you would most likely need to put it into a text file as vbscript and im sure autoit can do a lot with the data if it was in a text file.



SHARE:
+ Post New Thread

Similar Threads

  1. VBS Change File on a Certain Line?
    By Samson in forum Scripts
    Replies: 7
    Last Post: 31st August 2007, 11:52 AM
  2. AutoIt Script Help - Get Last Changed File
    By russdev in forum Scripts
    Replies: 8
    Last Post: 8th August 2007, 06:34 AM
  3. line managers?
    By markcuk in forum General Chat
    Replies: 52
    Last Post: 18th July 2007, 09:07 PM
  4. Who is your line manager?
    By Midget in forum General Chat
    Replies: 36
    Last Post: 12th March 2007, 12:15 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •