Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Hiding word in built styles and displaying only the custom styles

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Styles and formatting - 18 Dec 2007 10:50 GMT
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
NZ VBA Developer - 18 Dec 2007 22:19 GMT
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.
Signature


> in the Hi,
>
[quoted text clipped - 10 lines]
> Thanks,
> Shikha
Styles and formatting - 19 Dec 2007 03:54 GMT
So can u please let me know any other person who can help me in this regard.

> 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
[quoted text clipped - 15 lines]
> >
> > Thanks in advance
Styles and formatting - 19 Dec 2007 03:56 GMT
> in the Hi,
>
[quoted text clipped - 9 lines]
>
> Thanks,
Stefan Blom - 19 Dec 2007 11:43 GMT
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.

Signature

Stefan Blom
Microsoft Word MVP

> in the Hi,
>
[quoted text clipped - 10 lines]
> Thanks,
> Shikha
Styles and formatting - 19 Dec 2007 13:01 GMT
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.

> 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
[quoted text clipped - 18 lines]
> > Note : If any code needs to be written in the template then please let me
> > know that also.
Stefan Blom - 19 Dec 2007 13:32 GMT
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.

Signature

Stefan Blom
Microsoft Word MVP

> Thanks for the Help Stefan it work fine ...but can you please tell if I
> have
[quoted text clipped - 38 lines]
>> > me
>> > know that also.
Styles and formatting - 20 Dec 2007 12:52 GMT
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

> 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,
[quoted text clipped - 49 lines]
> >> > me
> >> > know that also.
Stefan Blom - 27 Dec 2007 10:55 GMT
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.

Signature

Stefan Blom
Microsoft Word MVP

> Could please tell me how can i achieve the same thing thru. VBA
> programming.
[quoted text clipped - 66 lines]
>> >> > me
>> >> > know that also.
Ken - 27 Dec 2007 21:52 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.