Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    conversion from 'text' to 'table' (All)

    Hi

    I need to process few hundred documents (probably on going as well) to produce tables from the text.

    The original documents look something like this. One or more para with a process number relating to previous para(s). For example:

    aslkdja saslkdjlaskjdals dlkasj dslkadj laksjd laskjdlaksdjlaksjdlkas djlkasjdlaksjdlkasjd lkajsdlkasjd
    alsdjasldj alksdj laskask dalksjdlaskjdasl kjlaskdja sldkjasldkjasldkjlaksdj laskdj lasjkdlasj daslkd
    (ABCD0040s)
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbb b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbb b b b b
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
    (ABCD0063s)
    cccccccccccccccccccccccccc ccccccccccccccccccccccc
    (ABCD0900s)

    Now I need to turn the above information into a table with 2 rows 1 col followed by the description in the paras. Please see the attachment as it is easier to show what I need.

    Could the above be done using macros or am I asking a stupid question?
    Attached Images Attached Images
    Thanks.
    Robie

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

    Re: conversion from 'text' to 'table' (All)

    Could you attach a small sample document that looks like the real ones but with dummy text?

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: conversion from 'text' to 'table' (All)

    Sorry - I should have done this from the beginning. Small sample/dummy doc attached.

    I have noticed that the 'para' text may also have something within the backets () as well. So will need to cater for this.
    Attached Files Attached Files
    Thanks.
    Robie

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

    Re: conversion from 'text' to 'table' (All)

    The document contains what looks like headings, such as 'System Configuration' and 'Trade Reporting'. How should these be treated?

  5. #5
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: conversion from 'text' to 'table' (All)

    Sorry again. Yes they are heading of sorts but there is no way to know if this a heading or not - as far as I can tell. Will probably need to take care of it post processing, i.e. treat it as standard para text (& then remove it once tables are generated).

    These are not my docs so don't know the history.
    Thanks.
    Robie

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

    Re: conversion from 'text' to 'table' (All)

    Try this macro as starting point:
    <code>Sub Convert2()
    Dim strText As String
    Application.ScreenUpdating = False
    With Selection.Find
    .ClearFormatting
    .Text = "(*)(^13(*)^13)"
    .Replacement.ClearFormatting
    .Replacement.Text = "21"
    .MatchWildcards = True
    Selection.HomeKey Unit:=wdStory
    .Execute Replace:=wdReplaceAll
    Selection.HomeKey Unit:=wdStory
    .Text = "^13(*)^13"
    .Replacement.Text = ""
    Do While .Execute(Replace:=wdReplaceNone)
    Selection.MoveStart Count:=1
    strText = Mid(Selection.Text, 2, Len(Selection.Text) - 3)
    With ActiveDocument.Tables.Add(Range:=Selection.Range, _
    NumRows:=2, NumColumns:=2)
    .Cell(1, 1).Range.Text = "References"
    .Cell(1, 2).Range.Text = strText
    .Cell(2, 1).Range.Text = "Title"
    End With
    Loop
    End With
    Application.ScreenUpdating = True
    End Sub
    </code>
    You may need to modify it to suit your needs, and you'll have to inspect the result to see if 'post processing' is necessary.

  7. #7
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: conversion from 'text' to 'table' (All)

    Hans

    This is most excellent. Perfect. What can I say. How do you know all this stuff? I thought I would be asking a stupid and what I wanted would not be possible. I may tweak it a little (table formatting type stuff) otherwise IT JUST WORKS BRILLIANTLY. I will have to study your macro to understand what you did though.

    Thanks several times over Hans. You have saved me 100 of hours of laborious work.
    Thanks.
    Robie

Posting Permissions

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