.doc to csv convert

Posted on 2008-11-13
Last Modified: 2012-05-05
I have a .doc file that I need to convert to .csv. Each record has 8 lines. ie:

Oz Accomodations
FirstName LastName
123 Main Road
City KS, 66214
Phone: 913-555-1212
Fax: 913-555-1234
firstname-lastname at adomain.zzz

need to convert each record into one line .csv file. I had the instructions and now cannot find them.
** edited the sample above so there is no chance it has personal info - b0lsc0tt **

Open in new window

Question by:akiles99
    LVL 35

    Expert Comment

    by:Joseph Daly
    Well heres how I did it.

    1. Open the doc in word
    2 Select all text and copy
    3. Open Excel
    4. Select cell A1 and select past special
    5. select the option to paste text only

    At this point you should have something that looks similar to your word doc but in excel.

    7. Select each the rows for each entry and copy.
    8. Paste special and then transpose. The entry will now be in a single line
    9 Repeat for all the other entries

    I have attached an excel doc where you are ready to perform the copy/paste special transpose step.

    Author Comment


    I know how to use transpose i'm looking for an better option like any macros.Since it has 200 records...
    LVL 54

    Accepted Solution

    I came up with some VBA code that would do this for you.  The code is in the snippet below.  To use it you need to open the VB Editor in Word (Alt + F11).  Access a code page for the sheet or workbook and paste the routine below in.  You can run it in the editor and it will create a new file as you need it.  You would then need to save it with the name you want.
    Let me know if you have a question or need more info to use it.

    Sub Convert2CSV()
        Dim p As Paragraph
        Dim str As String
        Dim line As String
        For Each p In ActiveDocument.Paragraphs
            line = Trim(Replace(Replace(p.Range.Text, Chr(13), ""), Chr(10), ""))
            If line = "" Then
                str = Left(str, Len(str) - 1) & vbCrLf
                str = str & """" & line & ""","
            End If
        'MsgBox str
        Set oDoc = Application.Documents.Add
        ActiveDocument.Range.Text = str
    End Sub

    Open in new window


    Author Comment


    It is working fine.This is a word macro right?

    LVL 54

    Expert Comment

    I believe it would actually be considered VBA script.  From what I have read macros are used less and even seem to have changed.  Maybe that is just a change and not really a sign they aren't supported.  I still see the option to Record and depending on how you try to run that routine it could be accessed from a "macros" list.  I guess the answer is at least partially Yes, it is a macro but I don't know that I would use that term for it.  Since I make the scripts and run them from the VB Editor I have thought there was a difference.  If you are curious about the difference it would be worth opening a question for it.  I am sure other experts can explain the difference better or even just how the words are used.
    I am glad it did what you need.  Let me know if you have any other questions for this.

    Author Closing Comment

    Thank u Mr.Admin:)Really thanks for ur time....
    LVL 54

    Expert Comment

    I'm glad I could help.  Thanks for the grade, the points and the fun question.

    Author Comment

    Actually i like to learn what are the things we could make using word and excel that's why i have posted the question.

    And got a result from an expert...

    Thanks for ur help...

    EE rocks!!!

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
    Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
    This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
    This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now