excel macro to copy the word document to new excel workbook

S

Shasur

Hi

You can try developing the following code

Sub CopyDoc2Excel()

Dim wdApp As Word.Application, wdDoc As Word.Document

On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then 'Word isn't already running
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0

Set wdDoc = wdApp.Documents.Open("c:\sample.doc")
wdApp.Visible = True

wdDoc.Activate

wdDoc.Content.Copy
Range("A1").PasteSpecial xlPasteAll

'Close the document
wdApp.ActiveDocument.Close (wdDoNotSaveChanges)
'Close out of Word
wdApp.Quit (wdDoNotSaveChanges)



End Sub


Cheers
Shasur
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top