dcsimg
Results 1 to 4 of 4

Thread: Word macro for importing styles

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2019
    Posts
    3

    Word macro for importing styles

    I'm looking for a way to import styles from a template into a document. Here's the functionality I'd like:
    * Import styles from template to document, overwriting any styles having the same name
    * Delete any styles from the document that are not in the template
    * Skip deleting styles that throw an error when trying to delete them (some built-in word styles)

    I have not found a way to do this using the standard import styles functionality since it doesn't seem to have a convenient way to identify and delete styles that are not in the template. Deleting all the styles in document before importing from the template doesn't work because many of the styles may be the same in the document and template, and text originally formatted with those styles will lose the style association and revert to Normal style. Consequently, I suppose I would need a macro to do this.

    The macro should run from within the document that will be importing the styles, and should prompt for the location of the template containing the desired styles.

    Would this be difficult to do in a macro? My macro experience is limited to recording macros and then modifying them to meet mey needs, with a lot of help from online resources and forums like th

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2019
    Posts
    3

    Re: Word macro for importing styles

    Forgot to mention, I am using Word 2007 - Visual Basic 6.5

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,441

    Re: Word macro for importing styles

    if you want to post a sample of template and a word document, i will see if i can do some sample code
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2019
    Posts
    3

    Re: Word macro for importing styles

    Template and sample document attached in a single zip file (could not attach dot file).Attachment 169989Sample doc.zip

    TIA

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width