Hi
I am going to modify a macro to extract data from MS Word documents. I run below mentioned macro but in the beginning where there is :
('Set a reference (Tools - References) to the
'Microsoft Word x.0 Object Library)
I don’t know what should I do.
And also I face error on:
(Dim wdApp As Word.Application)
May somebody help me?
The complete macro is following.
rgds
hme
Sub GetDataFromWord()
'Set a reference (Tools - References) to the
'Microsoft Word x.0 Object Library
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim sFile As String
Dim rInput As Range
'Define row and column of data in table
Const lROW As Long = 2
Const lCOL As Long = 2
'Specify file that contains table
sFile = "C:\Documents and Settings\Hashemi\Desktop\Macro test\test.doc"
'instantiate Word and open document
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open(sFile)
'define range where data goes
Set rInput = Sheet1.Range("a1")
'Copy value from table and paste to cell
With wdDoc.Tables(1)
.Cell(lROW, lCOL).Range.Copy
rInput.PasteSpecial xlPasteValues
End With
wdDoc.Close False
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
End Sub
Bookmarks