Results 1 to 9 of 9
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Strip out text (VB6)

    With the attached PNG I have documents stored in a designated folder on the network.
    The PNG shows some of the content of the text doc. From what I can tell, and this is part of what I'm after, any "New" parts required, are preceded by "070".

    I would like to search thru the doc for anything preceded with the 070 and merge the data on a Word doc.
    If possible put the extracted text in some kind of order, ie:

    Part No, Guide No, Description, Price.

    Any help to get me started would be appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Strip out text (VB6)

    Dave,

    How would you like to "merge the data on a Word doc"? Do you mean some kind of mail merge, or do you want to insert the data into predefined positions in a Word document, or ...?

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Strip out text (VB6)

    Hans

    My goal would be to insert the extracted data in some kind of legible order.
    I suppose some kind of place holder type of thing. The only thing I feel would be difficult, is that we never know how many new parts there would be !
    See the attached txt

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Strip out text (VB6)

    The attached code may give you some ideas how to go about it. You must set a reference to the Microsoft Word n.0 Object Library in Project | References, and substitute the appropriate paths and filenames for the text file and Word document.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Strip out text (VB6)

    What can I say !! Brilliant <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Strip out text (VB6)

    Hans

    Having a couple of issues here with the attached example.
    I can successfully strip the Chassis Number and thought I could use FindReplace, an error occurs Object not supported.

    The other issue , I have added headers to the data, but they are inserted at the start of the doc.

    Am I making sense ?

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Strip out text (VB6)

    Selection is a property of the Application (or Window) object in Word, not of a Document, so instead of

    With wrdDoc.Selection.Find

    you must use

    With wrdApp.Selection.Find


    > I have added headers to the data, but they are inserted at the start of the doc.

    The line

    Set myRange = ActiveDocument.Range(0, 0)

    explicitly refers to the start of the document. If you want the text in the page header, use this:

    Set myRange = wrdDoc.Sections(1).Headers(wdHeaderFooterPrimary). Range

    Or did you mean something else?

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Strip out text (VB6)

    I think I misunderstood your question about the headers. The attached version of the code moves to the end of the text in the document before setting the tab positions and inserting the headers.

  9. #9
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Strip out text (VB6)

    As ever, problem solved.

    Thanks for the extended help on this.and hope it's useful to others.

Posting Permissions

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