+ Reply to Thread
Results 1 to 2 of 2

Macro - Copy and Paste from Excel to Word

  1. #1
    Registered User
    Join Date
    05-28-2011
    Location
    NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Macro - Copy and Paste from Excel to Word

    I want to extract cell data from an open Excel Spreadsheet to an open Word Document by means of a Macro Shortcut Key. The section in the word document I need to paste data to is a typical three line format for NAME, ADDRESS, CITY/STATE/ZIP. The cells in the Spreadsheet I need to copy from are the first five in any given row. For instance A1 = John Smith, B1 = 123 Somewhere Lane, C1 = anywhereville, D1 = NJ, E1 = 01234. There are subsequent cells afterwards with additional data, but I don't need them. I want to be able to simply click on the first cell of whatever name I'm working on and have the macro copy and paste that cell along with the next four (text only - no format), into their appropriate places in the section of the word document I mentioned earlier. I know how to use mail merge, but that's for a large chunk of letters. Sometimes all I need is to occasionally send out one letter, and this macro would help speed things up instead of copying the name from the spreadsheet, paste it into word, and so on and so on. This might seem laughably easy to some, but I've looked high and low for the right way to write this code, but to no avail, I'm at an impass. Any help would be greatly appreciated. Thanks your time and patience.
    Last edited by thegoodofall; 05-28-2011 at 02:58 PM.

  2. #2
    Forum Contributor sauerj's Avatar
    Join Date
    11-11-2009
    Location
    Lafayette, IN
    MS-Off Ver
    Excel 2019
    Posts
    163

    Re: Macro - Copy and Paste from Excel to Word

    Yes, this does sound tricky. The code could be an Excel macro. You'd put the cursor (as you say) on the left most cell and engage the macro. It would copy the cells of that row (Ax - Ex), then it would move over to Word and paste the values in "transposed" form, each cell's value occupying a separate line.
    The tricky issue is "How do you get VBA code in Excel to continue doing stuff once it has moved over to the Word application?", where the object commands are different.
    For me, I don't know how to do this.

    So, I considered a more manual approach. This isn't exactly what you want, but it works almost as good:
    1) Manually select the Excel cells that you want to copy (either just cells Ax-Ex, or the whole row if no cells right of column-E are populated). Copy selection to the clipboard (via 'Cntrl-C').
    2) Manually move to the desired Word file and manully put cursor at desired insertion point.
    3) Invoke the following macro via your desired shortcut key-combination. I have included comments on each line to explain each line's purpose. The macro results with the text in the format that you prescribed.

    Excluding the manual selection of the Excel cells and the manual move to Word and manually positioning the cursor in Word, at least the harder part of parsing the table cells up into separate left-justified paragraphs is automated. I hope this gets you a step closer to your needs!

    A possible variant idea: You could build another, fairly simple macro in the Excel file (with a similar shortcut key combo) that automates the Excel portion of the above tasks: 1) copying the selected cells and 2) moving over to the Word application. Then, you'd only have to manually position the cursor in Word followed by invoking the following macro. ... Regards, sauerj
    Please Login or Register  to view this content.

+ 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