RE: Limit bullet and numbering choices by gordon(dot)bentleymix(at)gmail(dot)com>
gordon(dot)bentleymix(at)gmail(dot)com>
Wed Jun 18 19:19:00 PDT 2008
Here's some sample code to help get you started.
Sub Numbering()
If Documents.Count < 1 Then
MsgBox "There are no open documents.", vbCritical, "Numbering"
Else
Dim SelStyle As Style
With Selection
Set SelStyle = .Style
Select Case SelStyle
'*** If the current style is a built-in List Number style, then
make it Body Text ****
Case "List Number", "List Number 2", "List Number 3", "List
Number 4", "List Number 5"
.Style = "Body Text"
'****Any other style, apply the List Number style ***
Case Else
.Style = "List Number"
'*** This code looks to see if the previous list should be
continued ***
Dim styCurrentStyle As Style
Dim styPreviousStyle As Style
Set styCurrentStyle = .Style
On Error Resume Next
Set styPreviousStyle = .Range.Previous.Style
If styCurrentStyle <> styPreviousStyle Then
Dim ltListTemp As ListTemplate
Set ltListTemp = .Style.ListTemplate
.Range.ListFormat.ApplyListTemplate
ListTemplate:=ltListTemp, ContinuePreviousList:=False
End If
End Select
End With
End If
End Sub
Sub Bullets()
If Documents.Count < 1 Then
MsgBox "There are no open documents.", vbCritical, "Bullets"
Else
Dim SelStyle As Style
With Selection
Set SelStyle = .Style
Select Case SelStyle
'*** If the current style is a built-in List Bullet style, then
make it Body Text ***
Case "List Bullet", "List Bullet 2", "List Bullet 3", "List
Bullet 4", "List Bullet 5"
.Style = "Body Text"
'*** Any other style, apply the List Bullet style. ***
Case Else
.Style = "List Bullet"
End Select
End With
End If
End Sub
Note that in my "production" version I do a lot more. For example, I also
have special styles for lists in tables, so I check to see if the selection
is in a table first. If it is, then I also check to make sure that the "Table
List" style is available (because it's a user-defined style so it might not
be). However, this should give you some idea of what I'm talking about.
--
Cheers!
Gordon
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
"Gordon Bentley-Mix" wrote:
> List Bullet and List Number styles are native to Word - that is, there are
> existing styles called: 'List Bullet', 'List Bullet 2', etc.; and 'List
> Number', 'List Number 2', etc. I'm suggesting that you use standard Word
> functionality to define the List Bullet and List Number styles to match the
> corporate standard, and then write a macro that will apply the appropriate
> style whenever the user clicks on a toolbar button. I'm also suggesting that
> this macro be written so that if the style applied to the current selection
> is already List Bullet or List Number, the macro resets the style back to
> Body Text or Normal or whatever is standard for general text in the report.
>
> You can write this macro is such a way that when the user tries to invoke
> the standard Word functionality that's available through the "Formatting"
> toolbar for applying bullets or number, your macro runs instead and applies a
> style. (Getting this to work with the "Format | Bullets and Numbering..."
> menu command may be a bit more difficult.)
>
> Alternatively, you can create a custom toolbar in your 'Report' template for
> providing access to your macro. This is what I do, although as I said in my
> previous post, I do this through a global template so that the corporate
> standard styles are used in _all_ documents rather than just those based on a
> particular template. In addition, I use the button faces from the "Bullets"
> and "Numbering" buttons on the Word "Formatting" toolbar on my custom
> toolbar. I do this so that users think they're using the native Word
> functionality.
>
> Step one is to set up the List Bullet and List Number styles. Step two is to
> write code to apply (and remove) these styles. Step three is to figure out a
> way to provide access to the code - either through a custom toolbar or by
> structuring the code in such a way that the native "Bullets" and "Numbering"
> buttons (and the menu command if desired) are repurposed.
>
> I can help you with step two (to a limited degree) but I'll leave it up to
> you do steps one and three, as all that is required for these steps is
> general knowledge of Word.
> --
> Cheers!
> Gordon
>
> Uninvited email contact will be marked as SPAM and ignored. Please post all
> follow-ups to the newsgroup.
>
>
> "Associates" wrote:
>
> > Thank you Gordon for your reply.
> >
> > I'm not sure of how to create List Bullet and List Number styles as a
> > standard "bullets and numbering". Sorry for asking that question. I went to
> > View - toolbars and select "customise" thinking that i could create a
> > separate toolbar for a list bullet and number but to no avail. would you be
> > kind to show me how?
> >
> > Thank you in advance
> >
> >
> >
> > "Gordon Bentley-Mix" wrote:
> >
> > > I don't think there's any easy way to limit or restrict the bullets and
> > > numbering galleries; Word pretty much lets the user do whatever they want in
> > > this regard.
> > >
> > > However, you can make it easier for the user to use the 'standard' bullets
> > > and numbering by creating List Bullet and List Number styles. You can then go
> > > one step further and make the application of these styles available through a
> > > macro. If the macro is set up correctly, it can even be used as a replacement
> > > for the standard Word functionality and invoked through the related menu
> > > commands and toolbar buttons. It's just a matter of giving the procedures the
> > > correct name.
> > >
> > > I face this problem frequently with several of my clients, and usually the
> > > requirement is not limited to documents based on just one template; they want
> > > the corporate standard style used in _all_ documents. I approach it through
> > > the use of a global add-in that displays a toolbar with buttons for bullets
> > > and numbering (among others). These buttons use the standard faces so the
> > > user comes to associate them with the standard Word functionality. However,
> > > the macro behind these buttons differs from native Word in that it actually
> > > applies a style to the selection instead of adding bullets or numbering to
> > > the current style. Clicking the same button in a bulleted/numbered paragraph
> > > sets the style back to Body Text (altho it could just as easily be Normal
> > > instead).
> > >
> > > I also have 'higher level' styles (List Bullet/Number 2, 3, etc.) configured
> > > to match the corporate standard and provide ersatz 'Increase/Decrease Indent'
> > > buttons to apply these styles as well.
> > >
> > > The coding for this is pretty straight forward, so I won't provide a sample.
> > > However, I'm happy to provide direction and feedback on any solution you
> > > might develop.
> > > --
> > > Cheers!
> > > Gordon
> > > The Kiwi Koder
> > >
> > > Uninvited email contact will be marked as SPAM and ignored. Please post all
> > > follow-ups to the newsgroup.
> > >
> > >
> > > "Associates" wrote:
> > >
> > > > Hi,
> > > >
> > > > I'm working on a template that is to be used to create a standard word
> > > > document report customised for the use of our company. When it comes to
> > > > bullet and numbering, my question is whether there are any ways of limiting
> > > > the choices here. This is to prevent different users from selecting different
> > > > bullet points in report making process. Hence, i was thinking if there is
> > > > only one choice there for them to use, then users would have little options
> > > > to go for a different one. Is there any coding involved here? or it this
> > > > possible?
> > > >
> > > > BTW, i use office 03.
> > > >
> > > > Thank you in advance