View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default How to open & copy paste a word document in excel using macros?

Hi Amit

Try the below which copies the 1st table from the word document to excel
active sheet range A1

Sub Macro2()

Dim strFile As String, wrdApp As Object, wrdDoc As Object

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Word Documents", "*.doc", 1
.InitialFileName = "C:\"
.Show
strFile = .SelectedItems(1)
End With

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = False
Set wrdDoc = wrdApp.Documents.Open(strFile, ReadOnly:=True)

wrdDoc.Tables(1).Range.Copy
Range("A1").PasteSpecial xlPasteValues
wrdDoc.Close False

Set wrdDoc = Nothing
Set wrdApp = Nothing


End Sub

--
Jacob (MVP - Excel)


"Amit Raokhande" wrote:

Dear Friends,

I wanted to create an excel macro which will do the following:
-Ask for a path to open a word document
-Copy and paste data from word (which is in table format) to excel

Could you please assist me?
If possible please also mail me your answers at
Thanks in advance for your help!!!