Microsoft Word data to Excel Columns

HockeyDiablo

Board Regular
Joined
Apr 1, 2016
Messages
182
Is it possible at all to cut the first top 5 lines in a Word Document and have them send over to an Excel table?

Word Data:

ALL100 ALL RECREATION
1111 LAYES DRIVE BURNSVILLE
MN 55337- JERRY KERRY
(952)890-7000 (952)700-1067
WHIRLPOOL TUBS, BARS, STOOLS, POOL & FOOSBALL TABLES

In Excel as:

ABCDEFGHIJ
1ACCTEXHIBITORADDRESSCITYSTATEZIPCONTACTPHONECELLDESCRIPTION
2ALL100ALL RECREATION1111 LAYES DRIVEBURNSVILLEMN55337JERRY KERRY952-890-7000952-700-1067WHIRLPOOL TUBS, BARS, STOOLS, POOL & FOOSBALL TABLES

<tbody>
</tbody>


Thanks in advance. Im not sure this is possible, or I am going at this the wrong way...

-J
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
For the most part, this is fairly straightforward. However, this is no reliable way of separating the address and city from a string like that, since you don't have anything to indicate where the address ends and the city name (which might have two or more words) begins.
 
Upvote 0
The information has similar spaces involved between the fields. I thought I could run a replace and place like a ¥ symbol and use that as a delimiter once in Excel
 
Upvote 0
The information has similar spaces involved between the fields
That's irrelevant when you can't tell from the Word document, what's an address and what's a city name. For example, try the following with the data you posted:
Code:
Sub Demo()
Dim xlApp As Object, xlWkBk As Object, xlWkSht As Object, StrTxt As String
' Test whether Excel is already running.
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
'Start Excel if it isn't running
If xlApp Is Nothing Then
  Set xlApp = CreateObject("Excel.Application")
  If xlApp Is Nothing Then
    MsgBox "Can't start Excel.", vbExclamation
    Exit Sub
  End If
End If
On Error GoTo 0
xlApp.Visible = True
Set xlWkBk = xlApp.Workbooks.Add
Set xlWkSht = xlWkBk.Sheets(1)
' Update the workbook.
With ActiveDocument
  StrTxt = Split(.Paragraphs(1).Range.Text, vbCr)(0)
  xlWkSht.Range("A1").Value = Split(StrTxt, " ")(0)
  xlWkSht.Range("B1").Value = Replace(StrTxt, Split(StrTxt, " ")(0), "")
  StrTxt = Split(.Paragraphs(2).Range.Text, vbCr)(0)
  xlWkSht.Range("D1").Value = Split(StrTxt, " ")(UBound(Split(StrTxt, " ")))
  xlWkSht.Range("C1").Value = Trim(Replace(StrTxt, xlWkSht.Range("D1").Value, ""))
  StrTxt = Split(.Paragraphs(3).Range.Text, vbCr)(0)
  xlWkSht.Range("E1").Value = Split(StrTxt, " ")(0)
  xlWkSht.Range("F1").Value = Split(StrTxt, " ")(1)
  xlWkSht.Range("G1").Value = Trim(Replace(Replace(StrTxt, xlWkSht.Range("E1").Value, ""), xlWkSht.Range("F1").Value, ""))
  StrTxt = Split(.Paragraphs(4).Range.Text, vbCr)(0)
  xlWkSht.Range("H1").Value = Split(StrTxt, " ")(0)
  xlWkSht.Range("I1").Value = Split(StrTxt, " ")(1)
  StrTxt = Split(.Paragraphs(5).Range.Text, vbCr)(0)
  xlWkSht.Range("J1").Value = StrTxt
End With
' Switch to the Excel workbook
Set xlWkBk = Nothing: Set xlApp = Nothing
End Sub
Then try it again with a city whose name has two words.

Ask yourself: How would a macro recognise how many words a city name has?
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,923
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top