If you want to copy the content of a word document to excel. Snapshot below-
Here is the code-
Sub test()
Dim doc As New Word.Application
doc.Visible = True
' TOOL -> REFRENCE-> MICROSOFT WORD
Documents.Open "C:\Documents and Settings\achamanlalko\Desktop\WORD TABLE.doc"
Documents(ActiveDocument.Name).Activate
'
' method 1
ActiveDocument.Tables(1).Range.Copy
ThisWorkbook.Sheets(1).Range("j1").PasteSpecial xlPasteValues
' method 2
k = 1
For i = 1 To ActiveDocument.Tables(1).Range.Rows.Count
For j = 1 To ActiveDocument.Tables(1).Range.Columns.Count
Cells(i, j) = ActiveDocument.Tables(1).Range.Cells(k)
Cells(i, j) = Application.WorksheetFunction.Clean(Cells(i, j))
k = k + 1
Next
Next
doc.Quit
End Sub
Word Documnet
Excel Macro File
Showing posts with label Copy data from Word Table to Excel. Show all posts
Showing posts with label Copy data from Word Table to Excel. Show all posts
Thursday, November 10, 2011
Subscribe to:
Posts (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
Macro to Export Range in Json Format Option Explicit Sub export_in_json_format() Dim fs As Object Dim jsonfile Dim rangetoex...
-
If you want to run SQL queries within Excel environment without connecting to any database, you can do it with creating the ADODB conn...