KeepOnWheels
New Member
- Joined
- May 14, 2015
- Messages
- 7
Hello Guys!
This is my first post here. Glad to be here.
I'm trying to import tables from Word file to my excel sheet with VBA macro:
My problem is that in the word table line breaks are used. Something like this:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Name if client: Hello
987888 Street Canada[/TD]
[TD]Customer No. 8855
Type: None[/TD]
[/TR]
[TR]
[TD]Name if client: The second
985888 Toronto[/TD]
[TD]Customer No. 8889
Type: None[/TD]
[/TR]
[TR]
[TD]Name if client: The third customer
98848788 Berlington[/TD]
[TD]Customer No. 7785
Type: Something[/TD]
[/TR]
</tbody>[/TABLE]
When I'm importing the data with the above method, the line break information get disappeared. I need to know where is the data separated because I need to past them to separate column.
Some of the information I can separate by finding different words and creating some rules but there are some data where no rule can be established.
How would you solve this?
Thanks for all your help!
This is my first post here. Glad to be here.
I'm trying to import tables from Word file to my excel sheet with VBA macro:
Code:
[COLOR=#405A04][FONT=Helvetica Neue]With wdDoc
TableNo = wdDoc.tables.Count
If TableNo = 0 Then
MsgBox "This document contains no tables", _
vbExclamation, "Import Word Table"
Exit Sub
'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
For gettable = 1 To TableNo
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
With .tables(gettable)
'copy cell contents from Word table cells to Excel cells
For iRow = 2 To .Rows.Count
For iCol = 1 To .Columns.Count
Cells(iRow + finalrow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
Next iCol
Application.StatusBar = "Importing table no. " & gettable & " / " & TableNo & ", line: " & iRow & " / " & .Rows.Count
Next iRow
End With
Next gettable
End With
[/FONT][/COLOR]
My problem is that in the word table line breaks are used. Something like this:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Name if client: Hello
987888 Street Canada[/TD]
[TD]Customer No. 8855
Type: None[/TD]
[/TR]
[TR]
[TD]Name if client: The second
985888 Toronto[/TD]
[TD]Customer No. 8889
Type: None[/TD]
[/TR]
[TR]
[TD]Name if client: The third customer
98848788 Berlington[/TD]
[TD]Customer No. 7785
Type: Something[/TD]
[/TR]
</tbody>[/TABLE]
When I'm importing the data with the above method, the line break information get disappeared. I need to know where is the data separated because I need to past them to separate column.
Some of the information I can separate by finding different words and creating some rules but there are some data where no rule can be established.
How would you solve this?
Thanks for all your help!