PDA

View Full Version : Solved: Set Auto-update styles in new doc



Gabor
04-30-2006, 03:22 AM
Hi All,
I have been reading these forums for quite some time before registering and it is good to see there are so many helpful people here. :friends:
I was never an expert in this field but I used to be able to modify existing codes to a certain extent. After more than four years with Star/OpenOffice I am a "re-convert" to MS Office.

Now my question.
All my new docs are based on Normal and all the styles I need are based on Normal. I would like to achieve that whenever I create a brand new Word doc, the box "Automatically update document styles" on the Templates and plug-ins panel should be checked. It is unchecked by default.
(My Office is Hungarian so I can only translate the names and captions back into English, sorry.)

I managed to record the following code:

Sub AutoUpdateStyles()
Documents.Add DocumentType:=wdNewBlankDocument
With ActiveDocument
.UpdateStylesOnOpen = True
.AttachedTemplate = "Normal"
End With
End Sub

This is not really good as I have to start it from inside Word already open by a separate macro button.

My capability goes as far as inserting code into the "ThisDocument" Module of Normal.

Would somebody be so kind as to let me have the code what I would have to insert there so that all my NEW docs further on should open with the facility of updating styles ON? (Already existing doc left untouched).

Thank you very much.

TonyJollans
04-30-2006, 09:53 AM
Hi Gabor,

Welcome to VBAX!

If the code is in ThisDocument of Normal, just rename it to Sub Document_New() and it will run whenever a new document based on Normal is created, and at no other time. However it will *not* run when you start Word with a new blank document by default, which may be a problem for you.

Gabor
04-30-2006, 12:31 PM
Hi Tony,
Thank you very much. I did so and now it works fine. :hi:
I can avoid the problem you referred to (starting Word with a new blank document) by substituting a shortcut to Normal for the now existing shortcut to MS Word in my taskbar.
Gabor

fumei
05-01-2006, 03:58 PM
All my new docs are based on Normal and all the styles I need are based on Normal. This is not a good idea at all.

Gabor
05-02-2006, 02:37 PM
Hi Gerry,
Thank you for your reflection.
I admit to have read opinions like yours but, unfortunately, I could never make out where else I would be supposed to keep my personal:
1. styles
2. autotexts
3. keyboard shortcuts
4. macros
5. macros which must be in ThisDocument module
6. toolbars
7. autocorrect entries.
In one single other dot file?
Or all of them in separate dot files respectively?
And if I wish to change one single facility from among the above I should find the one single dot which contains it and change it there?
And if so, what is the purpose of Normal.dot (apart from the fact that Word cannot live without it)?
Instead I chose to make copies of Normal.dot regularly when I change anything in it and if anything goes wrong I can revert to the last perfect copy.
Of course I would be happy if someone could point me to a link where I can have a comprehensive answer for the above.
Thank you.

fumei
05-03-2006, 11:13 PM
It is a matter of thoughtful design.

FinanceStuff.Dot - all your finance document come from this template with appropriate macros, and autotext, and styles


PersonnelStuff.DOT - the template that contains all the forms and macros and autotext approrpiate for that department.

GeneralStuff - for general stuff; macros, styles, autotext.

Most places do not need that kind of sophistication - it depends on whether good templates have been designed...and are BEING USED. If they are not being used properly, then all of this is moot, and a waste of time.

These other containers of styles, macros, autotext can be stored on a server and either:

1. loaded globally so always available;
2. loaded on demand.

Gabor
05-05-2006, 01:03 AM
Thank you for the explanation. Since I use few styles but lots of macros it seems to be reasonable for me to keep the seldom used macros in separate dot files to load them on demand. That will then ease the burden on my Normal.dot.