VBA Test for Active Outlined Numbered List 
Author Message
 VBA Test for Active Outlined Numbered List

Quote:
> If you place your cursor in the paragraph that has the
> style linked to an Outline Numbered List, is it then
> possible to create a VBA macro to test for the active
> list?

Yes.  You can use the Selection object to get the properties of the
paragraph or text where the cursor is positioned.  Next you can use the
ListType property of the ListFormat object to determine the type of list the
selection is.

Quote:
> If our users must modify their linked outline
> numbered list I would like to prevent them from selecting
> the wrong one. Therefore, when they need to modify I would
> instruct them to place their cursor in the first level and
> click on a button which will take them directly to the
> active Outline Numbered list/Customize.

Next, you can use the Dialog object to display the Bullets and Numbering
dialog and specify which tab to display on top.  As far as I know, there
isn't any way to display the Customize dialog, but by that time it is just a
click away

Also, you might consider overriding the Bullets and Numbering built-in menu
to do this.  You could place the subroutine in the ThisDocument module of a
custom template or the normal template and as long as the template was in
use/active, the Format, Bullets and Numbering menu command would run your
custom macro.

The following might help you decide how you want to do this.  Place it into
the ThisDocument module of a VBA document project (preferably the active
document). It will override the Format, Bullets and Numbering built-in menu
command and determine the type of list format used in the active selection.
If the active selection isn't formatted as a buttet or numbered list, it
will just display the Bullets and Numbering dialog in its normal view
(Bullet tab on top).

Sub FormatBulletsAndNumbering()
    With Selection.Range.ListFormat
        If .ListType = wdListListNumOnly Or .ListType = wdListMixedNumbering
_
                Or .ListType = wdListSimpleNumbering Then
            MsgBox "Numbered List"
            With Dialogs(wdDialogFormatBulletsAndNumbering)
                .DefaultTab = wdDialogFormatBulletsAndNumberingTabNumbered
                If .Show = 1 Then .Execute
            End With
        ElseIf .ListType = wdListOutlineNumbering Then
            MsgBox "Outline List"
            With Dialogs(wdDialogFormatBulletsAndNumbering)
                .DefaultTab =
wdDialogFormatBulletsAndNumberingTabOutlineNumbered
                If .Show = 1 Then .Execute
            End With
        Else
            MsgBox "Bulleted List"
            With Dialogs(wdDialogFormatBulletsAndNumbering)
                .DefaultTab = wdDialogFormatBulletsAndNumberingTabBulleted
                If .Show = 1 Then .Execute
            End With
        End If
    End With
End Sub

--
Lisa Wollin
Microsoft Corporation
http://www.*-*-*.com/

Disclaimer:  This posting is provided 'AS IS' with no warranties, and
confers no rights.

Please do not send email directly to this alias. This alias is for newsgroup
purposes only.

Quote:
> If you place your cursor in the paragraph that has the
> style linked to an Outline Numbered List, is it then
> possible to create a vba macro to test for the active
> list?  If our users must modify their linked outline
> numbered list I would like to prevent them from selecting
> the wrong one. Therefore, when they need to modify I would
> instruct them to place their cursor in the first level and
> click on a button which will take them directly to the
> active Outline Numbered list/Customize.

> I welcome any suggestions.



Sun, 06 Jun 2004 10:56:32 GMT  
 VBA Test for Active Outlined Numbered List
Try bunging the following into a macro,

Sub Get_Current_Template()
'
' Get_Current_Template Macro
' Macro created 20/12/01 by Name
'
Dim List_Format As ListFormat, List_Template As ListTemplate,
List_Template_Name As String

Set List_Format = Selection.Range.ListFormat
    If List_Format.ListType <> wdListNoNumbering Then
        Set List_Template = List_Format.ListTemplate
        If List_Template.Name = "" Then
            List_Template_Name = "Unnamed"
        Else
            List_Template_Name = List_Template.Name
        End If

        MsgBox List_Template_Name & " Level " & List_Format.ListLevelNumber,
, "List Template"
    End If
End Sub

Then create a button on a drop-down menu, by the normal method...
    right click on a toolbar,
    select the customize option from the bottom of the list,
    check the shortcut menus option from the bottom of the Toolbars list,
and a toolbar will appear.
    choose the Text drop-down list, and select the kind of item that suits
your numbered list, e.g. Headings, Linked text, Text etc.
    then go back to the customize dialog and select Macros from the commands
tab,
    select your new Get_Current_Template macro and drag it into the top of
the drop-down menu.
    repeat this for each of the text types that you will have outline
numbered.
    you can create your own button image, and edit the name of the menu item
to suit yourself, I chose an image of a Letter A with a question mark on it,
and changed the menu text to say "Which Template ?"
    now when you right click on an item of the types you've added the macro
button to, you will see your new feature.

I think the will do what you want.

:o)


Quote:
> If you place your cursor in the paragraph that has the
> style linked to an Outline Numbered List, is it then
> possible to create a vba macro to test for the active
> list?  If our users must modify their linked outline
> numbered list I would like to prevent them from selecting
> the wrong one. Therefore, when they need to modify I would
> instruct them to place their cursor in the first level and
> click on a button which will take them directly to the
> active Outline Numbered list/Customize.

> I welcome any suggestions.



Mon, 07 Jun 2004 17:55:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Outline Number Lists - legal numbering

2. How to differentiate b/w numbered and outline numbered list

3. Find Outline Parent from Outline Number???

4. TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

5. How to test in vba for floating point not a number values

6. VBA ,Office XP - How to list all active applications

7. List of VBA error numbers created when using Office 97

8. Copy and paste list numbering via VBA code.

9. Test for null value in Outline code field

10. 2002: sections & outline numbering

11. Determining the Outline Number of a paragraph

12. Getting paragraph outline number

 

 
Powered by phpBB® Forum Software