Hiding word in built styles and displaying only the custom styles

  • Thread starter Styles and formatting
  • Start date
S

Styles and formatting

in the Hi,

In my project i have to migrate from word 2000 to 2007 fo which i need to
hide all the built in styles available in word 2007 and display only the
custom styles which i have in the template normal.dotm.
Currently what is happening is styles are available in normal.dotm but when
i open a document style pane only show me some of my custom styles not all.
Please help me.

Note : If any code needs to be written in the template then please let me
know that also.

Thanks,
Shikha
 
N

NZ VBA Developer

Your uninvited email contact has been marked as SPAM and ignored. Unless you
want to contract for my services on a paid basis, please make all
communication through the forum.

FYI, I don't provide support for Office 2007 anyway.
 
S

Styles and formatting

So can u please let me know any other person who can help me in this regard.
 
S

Styles and formatting

Styles and formatting said:
in the Hi,

In my project i have to migrate from word 2000 to 2007 fo which i need to
hide all the built in styles available in word 2007 and display only the
custom styles which i have in the template normal.dotm.
Currently what is happening is styles are available in normal.dotm but when
i open a document style pane only show me some of my custom styles not all.
Please help me.

Note : If any code needs to be written in the template then please let me
know that also.

Thanks,
 
S

Stefan Blom

Open the template file. On the ribbon, click the Developer tab, and then
click Protect Document (in the Protect group). Click "Limit formatting to a
selection of styles." Click Settings. The dialog box allows you to choose
exactly which styles should be available. (You cannot remove the Normal
style, though; it will always be accessible.) When you are done, click OK.
Click Yes, Start Enforcing Protection, type a password if you want to, and
then click OK.

Note: If you cannot se the Developer tab, display it via Office button |
Word Options, Popular category.
 
S

Styles and formatting

Thanks for the Help Stefan it work fine ...but can you please tell if I have
to do same thing with the template (normal.dotm) then how can I achieve the
same thing.
As I want to that whenever the new document get open in any version of MS
Word by any other person only the my custom styles should be visible to him.

Will Wait for a positive response from your side.
Thanks in Advance.
 
S

Stefan Blom

To apply the settings to a template (and to all documents later created
from that template), just open the template as you would open a document,
via the Open dialog box.

Note that you may want to leave users' Normal templates alone, though, and
instead create a *custom* template that has these settings.

Since you mentioned Word 2000, I'd like to point out that restricting the
styles of a Word file is only possible with Word 2003 and later. In older
versions, the file(s) will be completely locked.

--
Stefan Blom
Microsoft Word MVP


in message
 
S

Styles and formatting

Could please tell me how can i achieve the same thing thru. VBA programming.
If i have to write code for it in the template how can i do so?

Thanks
 
S

Stefan Blom

Someone in this newsgroup is likely to know the answer. If you don't get a
reply in this thread, repost the question later.

Note, however, that VBA may not "fix" the fact that restricted styles are
not supported in versions older than Word 2003.

--
Stefan Blom
Microsoft Word MVP


in message
 
K

Ken

Sub SetStyleLocking()
Dim aStyle As Style
If Application.Version < 12 Then Exit Sub ' only run if Word
version is 2007 or above
For Each aStyle In ActiveDocument.Styles
With aStyle
.Locked = .BuiltIn
End With
Next aStyle
End Sub

The above macro should be run when the document is loaded, either by
the template or it can be attached to individual documents and run
from the macro:

Private Sub Document_Open()
SetStyleLocking
End Sub

If you want to also make available only the builtin styles that are
used in the document as well all user defined styles, then add after
the line " .Locked = .BuiltIn" the line:
.Locked = Not (.InUse And .BuiltIn)

I haven't tested in Word 2003 so I have limited the macro to run only
in Word 2007.

Documents created in Word 2007 and saved as .doc files can usually be
read in previous versions of Word. However, if in the earlier Word you
then try to execute VBA code that accesses certain style properties
then Word will crash. Error detection to prevent the crash does not
work and there seems to be no way of determining if the property of
the style is a nasty. Therefore, in earlier versions of Word, be very
careful about using VBA on styles that might have been created in Word
2007.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top