Word To Excel

  dazwm 09:34 27 Nov 2006

I have a word document that I want to convert/copy to excel. It is a table which is 3 boxes wide with name in box 1, address in box 2 and details in box 3. How do I do this so it is the same in excel. If I copy and paste it puts the address in different cells when I want it in one cell. I hope I have explained ok.

  Polopaul69™ 09:40 27 Nov 2006

Try paste special

  dazwm 09:46 27 Nov 2006

They were a few options in Paste Special, none of these done as I require.

  VoG II 09:46 27 Nov 2006

Sub ImportWordTable()
Dim wdDoc As Object
Dim wdFileName As Variant
Dim TableNo As Integer 'table number in Word
Dim iRow As Long 'row index in Excel
Dim iCol As Integer 'column index in Excel
wdFileName = Application.GetOpenFilename("Word files (*.doc),*.doc", , _
"Browse for file containing table to be imported")
If wdFileName = False Then Exit Sub '(user cancelled import file browser)
Set wdDoc = GetObject(wdFileName) 'open Word file
With wdDoc
TableNo = wdDoc.tables.Count
If TableNo = 0 Then
MsgBox "This document contains no tables", _
vbExclamation, "Import Word Table"
ElseIf TableNo > 1 Then
TableNo = InputBox("This Word document contains " & TableNo & " tables." & vbCrLf & _
"Enter table number of table to import", "Import Word Table", "1")
End If
With .tables(TableNo)
'copy cell contents from Word table cells to Excel cells
For iRow = 1 To .Rows.Count
For iCol = 1 To .Columns.Count
Cells(iRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
Next iCol
Next iRow
End With
End With
Set wdDoc = Nothing
End Sub

To use this, open a blank Excel workbook. ALT + F11 to open the Visual Basic Editor. Insert|Module and paste in the code above. Close the VBE. Go to a blank worksheet, Tools > Macros > Macro, click ImportWordTable and click the Run button.

  dazwm 09:57 27 Nov 2006

That kind of worked! When I run macro it said there 2 tables to insert and asked which one to import. It had 1 selected as default which I selected but box 2 and 3 were merged together. Box 1 was fine with the names in.

  dazwm 10:24 27 Nov 2006

Also when the info is imported into excel with the macro the address's in column 2 are joined together with no gaps i.e 14RadcliffeRoadLondon

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

Alice Saey's mesmerising animation for Dutch singer Mark Lotterman

iPad Pro 10.5in (2017) review

Comment faire une capture d’écran sur un Mac ?