#1
|
|||
|
|||
Style to be used in all documents (new and old)
Hi I've put a style into Normal.dot, but obviously each time I open an old document/template they are not there. I know the organiser, but too much to do each document. Plus format painter, but again, would rather just have the style in all documents, old and new. Thanks |
#2
|
||||
|
||||
You need to refresh the styles from the template in order to import the styles from the attached template into the currently active document.
Via the interface, you do this by ticking the setting of Developer Tab > Document Template > Automatically update document styles and pressing the OK button. Once this is done, I would recommend you go back into that dialog and turn it off again. The developer tab is not active by default in Word. If you haven't shown yours, go to File > Options > Customise Ribbon to turn it on.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
You probably do not want to leave that option turned on.
What happens when I send my document to someone else? Will Word mess up my formatting? Quote:
Put the following macro in your normal template: Code:
Sub UpdateMyStyleOnOpen() ' Charles Kenyon 2018-03-22 ' https://www.msofficeforums.com/word/38569-style-used-all-documents-new-old.html#post126054 ' ' UpdateMyStyleOnOpen Macro ' Copies named style from normal template to any document that is opened, overwriting existing style ' ' Rename as AutoOpen (instead of UpdateMyStyleOnOpen) and store in Normal.dotm template. ' Set variable strMyStyle to contain the name of style to be updated ' ' Dim strMyStyle As String strMyStyle = "Body Text" ' change this to be the style you want ' must enclose name in quotation marks ' Application.OrganizerCopy Source:=ThisDocument.fullname _ , Destination:=ActiveDocument.fullname, Name:=strMyStyle, _ Object:=wdOrganizerObjectStyles End Sub Installing Macros If you already have an AutoOpen macro, do not rename, but instead add the following line to the existing macro: UpdateMyStyleOnOpen |
#4
|
||||
|
||||
There is an alternative to Charles' focused approach which imports a single style from a specific template.
I use a much broader approach. The following macro will import every style from the attached template. The attached template is not always the Normal template but if you created the document yourself and didn't pay attention to which template you used then in all likelihood it is Normal.dotm. Code:
Sub RefreshStylesFromTemplate() ActiveDocument.UpdateStyles End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
Quote:
It imports a single style from the template that holds the macro (ThisDocument). If my advice is followed, that is the normal template. If named AutoOpen, it runs anytime any document (or template) is opened regardless of what is the attached template. |
#6
|
|||
|
|||
Thanks so much! Works on my home computer, now to do it at work!
Thanks so much! Works on my home computer, now to do it at work!
|
#7
|
|||
|
|||
It works, but I get an error when I open Word :-)
It comes up and says "command failed". Simple little dialog, but then continues. Bit annoying each time... any suggestions? Thanks M
|
#8
|
||||
|
||||
Which macro are you using? If the command is failing then it would help to know what your actual code is before hypothesizing on reasons why it might fail.
For instance, the one liner I supplied might fail if you ran it on a template instead of a document.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#9
|
|||
|
|||
I'm using this one
Sub UpdateMyStyleOnOpen()
' Charles Kenyon 2018-03-22 ' https://www.msofficeforums.com/word/...tml#post126054 ' ' UpdateMyStyleOnOpen Macro ' Copies named style from normal template to any document that is opened, overwriting existing style ' ' Rename as AutoOpen (instead of UpdateMyStyleOnOpen) and store in Normal.dotm template. ' Set variable strMyStyle to contain the name of style to be updated ' ' Dim strMyStyle As String strMyStyle = "Body Text" ' change this to be the style you want ' must enclose name in quotation marks ' Application.OrganizerCopy Source:=ThisDocument.fullname _ , Destination:=ActiveDocument.fullname, Name:=strMyStyle, _ Object:=wdOrganizerObjectStyles End Sub |
#10
|
|||
|
|||
Try
Code:
Sub UpdateMyStyleOnOpen() ' Charles Kenyon 2018-03-22 ' https://www.msofficeforums.com/word/3...tml#post126054 ' ' UpdateMyStyleOnOpen Macro ' Copies named style from normal template to any document that is opened, overwriting existing style ' ' Rename as AutoOpen (instead of UpdateMyStyleOnOpen) and store in Normal.dotm template. ' Set variable strMyStyle to contain the name of style to be updated ' ' Dim strMyStyle As String strMyStyle = "Body Text" ' change this to be the style you want ' must enclose name in quotation marks ' On Error Resume Next Application.OrganizerCopy Source:=ThisDocument.fullname _ , Destination:=ActiveDocument.fullname, Name:=strMyStyle, _ Object:=wdOrganizerObjectStyles End Sub Last edited by Charles Kenyon; 03-30-2018 at 03:43 AM. |
#11
|
|||
|
|||
Vba
Thank you! :-)
|
Tags |
#global style, #styles, #template |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Apply Heading Style When Combining Documents | snot369 | Word | 1 | 01-13-2017 11:04 AM |
Writing multiple documents of a certain style. | Darkstar_ | Word | 2 | 09-30-2016 12:02 PM |
How can I change the default style set so that it automatically applies to all documents? | writty | Word | 3 | 08-16-2015 09:47 AM |
Make a new Style available in legacy documents | BlueClearSky | Word | 3 | 11-22-2013 03:12 PM |
Change font style and size in multiple documents | fitkhan | Word | 1 | 04-27-2011 09:49 PM |