Currently we have a macro in word which selects a specifc table in the document ready to be copied to excel.
Im trying to automate this process by creating a macro in excel which will open the word file automatically and than copy the specifc table from the word document and paste it into the excel spreadsheet.
I have gone as far as opening the word document successfully but when i have copied over the code from word document macro and pasted it into the excel macro it does NOT work Debug error " run time error 450 Wrong number of arguements or invalid property assignment"![]()
![]()
![]()
The following code is in yellow when i click on debug
Sub Open_Word_Document_&Paste()
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
appWD.Documents.Open Filename:="D:\PROFILES\iltafr\My Documents\31AA.doc"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "project code"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.Copy
Selection.Find.ClearFormatting
With Selection.Find
.Text = "overall status"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdPasteDefault)
Selection.Tables(1).Select
' Remove all carriage returns - added 16/04/2007
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Tables(1).Select
Selection.Copy
End Sub
Please note I have done the macro upto the copying , once that works I will move onto paste active.paste shud do the trick. Anyway who knows how to fix the debug and enter the line of code that will paste it into the excel worksheet that would be great . Im new to this but very keen to learn![]()
Bookmarks