+ Reply to Thread
Results 1 to 3 of 3

Macro to copy & paste the contents of a docx file into xls?

  1. #1
    Registered User
    Join Date
    12-18-2008
    Location
    White Rock
    Posts
    76

    Macro to copy & paste the contents of a docx file into xls?

    I'm trying to figure out at the base level if it's possible to create a macro in a xls sheet that will automatically copy & paste the contents of a docx document into a new tab.

    If that is possible, I'll next be trying to understand how.

    Thank you very much.

    -Aaron

  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,258

    Re: Macro to copy & paste the contents of a docx file into xls?

    Hello Cheshire,

    The new Word format docx would first have to be converted from XML back to the older Word format of doc. The easiest way would be to save a copy of the docx as doc file. This can be done in VBA. The next steps depend on the information you want from the Word file. Without examples, we can't go any further.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-18-2008
    Location
    White Rock
    Posts
    76

    Re: Macro to copy & paste the contents of a docx file into xls?

    The .docx file is a report from an outsourcer,

    I want to extract the data associated with the respective categories to reformat their report and automatically assess inconsistencies; such as when their math is erronious, or when a category has no data.

    If I manually open the .docx file and copy everything (ctrl+a), then past it into an excel sheet, the only consistency I have found is that the left aligned categories have their corresponding data somewhere to the right. I know enough about standard cell manipulations to search cells for the category name, then look for the contents of all right aligned cells in the same row and remove any extraneous spacing / tabbing. They are inconsistent with including some data in formatted tables, and some without. Pasting into excel seems to strip all that away to something I can work with.


    For example, if the following was part of their report:
    Please Login or Register  to view this content.
    I would like to copy this content out of the docx file, paste it directly into the workbook as a new excell sheet, add a new row to represent this entry in Sheet0, concatenate the values of type and system, copy over their time data without the extra spaces, carry over their time elapsed, then calculate the real time elapsed and flag it by changing the cell colour if there is a discrepancy.

    I know that's a lot, but at the moment I am just looking for a way to copy and paste the contents of a docx file into an excell sheet using a VBA macro based in the excel sheet for every .docx file in a single folder.
    Last edited by Cheshire; 08-04-2010 at 02:51 PM.

+ 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