.doc to csv convert

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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joseph DalyCommented:
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.
akiles99Author Commented:

I know how to use transpose i'm looking for an better option like any macros.Since it has 200 records...
b0lsc0ttIT ManagerCommented:
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

akiles99Author Commented:

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

b0lsc0ttIT ManagerCommented:
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.
akiles99Author Commented:
Thank u Mr.Admin:)Really thanks for ur time....
b0lsc0ttIT ManagerCommented:
I'm glad I could help.  Thanks for the grade, the points and the fun question.
akiles99Author Commented:
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!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.