Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Macro to point to folder of documents and replace styles from template?

    Hello,
    I am using MS Word 2010 and I need a macro that will:

    1. Point to a folder full of documents on my "C" drive (e.g. C:\Test)
    2. Find Template (.dotx) file in the same folder and open template.
    3. Loop through all the .docx/.doc files in the folder and replace the original styles in the documents with the desired template styles.

    There may be some variations on the best way to make this happen, but I will go with the easiest approach.

    Thanks in advance for your suggestions.

    Regards,

    Jim

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    What is the logic to be used to replace one style with another? Does the template contain style names that exist in the target documents? Or do styles need to be changed to a different name in the template?

    In short, your question is too general to give a specific answer but the way I would address this is:
    1. Troll through the documents to get an idea of the content we are looking at and the styles which have been used
    2. Modify the template to include style aliases of styles that need to be merged. Eg. If the template preferred style for content is "Normal" but Doc1 uses "Content" and Doc2 uses "Document Body" then I would change the template stylename to "Normal,Content,Document Body"
    3. Create a looping macro to go to each document and
    - Attach the template
    - Refresh the styles from the template
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    You asked essentially the same question a week ago, in this thread. So far I've not seen any indication that you've tried the solutions already offered.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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