hi all.
the code work properly to import tabel from ms word to excel
Code:
Sub ImportWordTable()
On Error GoTo errHandler
Dim wordDoc As Object
Dim wdFileName As Variant
Dim noTble As Integer
Dim rowNb As Long
Dim colNb As Integer
Dim x As Long, y As Long
x = 1: y = 1
wdFileName = Application.GetOpenFilename("Word files (*.docx),*.docx", , _
"Browse for file containing table to be imported") 'adjust this to the document type you are after
If wdFileName = False Then Exit Sub
Set wordDoc = GetObject(wdFileName)
With wordDoc
noTble = wordDoc.tables.Count
If noTble = 0 Then
MsgBox "No Tables in this document", vbExclamation, "No Tables to Import"
Exit Sub
End If
For k = 1 To noTble
With .tables(k)
For rowNb = 1 To .Rows.Count
For colNb = 1 To .Columns.Count
Cells(x, y) = WorksheetFunction.Clean(.cell(rowNb, colNb).Range.Text)
y = y + 1
Next colNb
y = 1
x = x + 1
Next rowNb
End With
x = x + 2
Next
End With
Set wordDoc = Nothing
Exit Sub
errHandler:
MsgBox "Error in generating tables - " & Err.Number & " - " & Err.Description
End Sub
i want to modified how to make code can import tabel with included format like border, shading, color.
this my attachment file
any help me out thank in advance
note:
i'm using Ms Office 2013
.susanto
Bookmarks