Share via

Mass Copy/Paste Macro

Anonymous
2016-08-22T10:57:47+00:00

Hi there, I hope someone can help me with a macro to do the following:

  1. Open a specific Word file (A) (always the same one).
  2. Open a Word file (B) (variable) in a specific folder, noting the location and filename.
  3. Select all text in file B, paste to file A.
  4. Close file B.
  5. Save the File A as a replacement of the original file B ie. same location and filename.
  6. Close File.

Repeat for all files found in a specified folder AND sub folders.

There are no issues of section breaks etc. just want to copy/paste the text from over 200 files from each original file, into the "new" format, and save as what it was before.

I hope I have explained it clearly enough :)

Many thanks in advance of any assistance :)

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Paul Edstein 82,861 Reputation points Volunteer Moderator
    2016-08-23T21:27:41+00:00

    As you may be aware, each Section in a document has three header and footer ranges. So,

    • How many sections does the source document contain?

    • How many headers & footers does each Section in the source document contain? If more than one Section, are these headers & footers linked to those of the previous Section(s)?

    • How many headers & footers do the target documents contain?

    • How many headers & footers does each Section in the target  documents contain? If more than one Section, are these headers & footers linked to those of the previous Section(s)?

    If there is a mis-match between the # headers & footers between the source & target documents, how do you want to handle that?

    A different approach you might consider is to not do a bulk update but, instead, use a Document_Open macro in your template (which I assume the target documents are attached to), to update each target document when it is next opened.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-08-23T07:28:38+00:00

    essentially yes

    some changes have been made to some of the styles attributes but your previous macro to me (applying new template to files in cluster of folders/subfolders) works wonders for that, but the new template also has a new layout of content in the H&Fs which your previous macro does not apply.

    as mentioned in the OP, there are no issues with section breaks.

    When we discussed the previous macro I asked about H&Fs not being applied and we never got a solution to that with that previous method.

    I thought coming from the other way - copying the body-content from one file to another (with the new H&Fs) would deal with the H&Fs as well as the style changes.

    Thanks for the quick reply :)

    additional - there is Different First Page attribute

    Was this answer helpful?

    0 comments No comments
  3. Paul Edstein 82,861 Reputation points Volunteer Moderator
    2016-08-23T06:59:51+00:00

    So all you really need to do is to update the Headers and Footers?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2016-08-23T06:47:28+00:00

    Thanks for the reply.

    All the documents are all based on the same template and style names BUT the Headers and Footers are different.

    Applying Template does not apply the "content" of the H&Fs :(

    Was this answer helpful?

    0 comments No comments
  5. Paul Edstein 82,861 Reputation points Volunteer Moderator
    2016-08-23T04:03:22+00:00

    Is the file B text all in a single format? Is the formatting in file A defined by a single Style? If so, why not just apply the file A Style to file B? Same goes for page layouts. If the data aren't all in the same format, and won't all have the same format applied, the process will be rather more complicated than merely copying & pasting.

    Was this answer helpful?

    0 comments No comments