+ Reply to Thread
Results 1 to 2 of 2

Copy specific table from word to Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    10-11-2007
    Posts
    1

    Copy specific table from word to Excel

    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

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Raz1978,

    Welcome to the forum. To make it easier for others to read your posts and respond to them, there a few rules posters should follow. You can review the rules by clicking on the link below. Since your new here, it isn't a big deal. In the future though, if you fail to post properly your post may be locked, or even deleted.

    Forum Rules

    Thanks,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1