Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a macro from an existing style?

    Forgive me if this has been asked already. I looked and found nothing. Is it possible to create a macro from an existing style? I created a series of styles that are not transferring to other documents; I thought if I created them as macros, then they would be available in every document I create. In any case, how do I create a macro from an existing style? Thanks.

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    You can create a macro that creates or redefines a style but most people just add the styles to a template and then use that template when creating a new document. The default template is named Normal.dotx and resides in your application data folder in the Microsoft/Templates folder.

    Note that in Windows Explorer, when double clicking a template you are creating a new document with that template attached, not actually opening the template itself. Right click it instead and choose Open if you want to modify the styles within it so they are always there in your new documents.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    New Lounger
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So, I have a simple style that I created that defines the font, the size of the font, and the formatting I want for that specific paragraph (e.g., Cambria, 12, left indent 1.5). I want to automate that with a keystroke (e.g., Ctrl+Alt+2). You're saying I can't do that without recording the macro from scratch? I can't tell Word, when I'm recording the macro, hey, just take what I did with that style and use it because that's exactly what I want? I seem to remember that I could do that in earlier versions of Word but maybe this went away in recent versions. Thanks.

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    You can still record macros for a whole lot of tasks and most likely this still includes creating styles. Assuming you are putting the macro into Normal then you will have the code available in all documents.

    If you want to record this as a macro then you will need to record the steps of CREATING the style to your requirements. Your first post specified that the style already exists so the macro recording would not capture this step because it doesn't occur when you are recording. If you are recording 'modifying' the style then the macro will only work successfully if that style already exists in the document.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    You are correct that there is no way I know of to grab all the formatting parameters of selected text or a style definition and make a macro that recreates that definition. Styles can be very complex and are at the heart of Word's formatting. Understanding Styles in Microsoft Word

    It is much more effective to simply copy the style from an existing template than it is to write or record a macro to recreate that style. Among other things, if you want to change the style in any way, with a macro, you will need to rewrite the macro. With copying a style from an existing template, you simply change the style in the template. You can do this copying manually using the Organizer. In recent versions of Word a simple copy and paste of text formatted in a particular style does this. Paul Edstein posted a macro recently that copies a style into all open documents. This could easily be modified to copy into only the active document or to copy into all documents in a particular folder.

    The link below has a macro that copies styles from a global template into the open (active) document.

    See http://www.addbalance.com/word/stylesheet.htm.
    Last edited by Charles Kenyon; 2013-06-28 at 13:56.
    Charles Kyle Kenyon
    Madison, Wisconsin

Posting Permissions

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