Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Change Caption Numbering Style (Word 2000/Windows 2000)

    Hello,

    I'm confused. I am finding that the following does not produce consistent results:

    sub ChangeNumStyle()
    dim dlgCap as Dialog
    set dlgCap = Application.Dialogs(wddialogInsertCaptionNumbering )

    with dlgCap
    .Label "APPENDIX"
    .FormatNumber = 0 ' should be for arabic numbering
    .Execute
    end with

    or

    with dlgCap
    .Label "APPENDIX"
    .FormatNumber = 2 ' should be for uppercase letters
    .Execute
    end with

    end sub


    If I run either of these with the FormatNumber set to 0 or 2 I do not get a consistent result. I get roman numerals, uppercase roman numerals, uppercase letters.

    I am trying to find an easy method of changing the number formt for captions without having to parse through every caption field.

    Anyone have a suggestion?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Change Caption Numbering Style (Word 2000/Windows 2000)

    Unless you have to use the dialog, I suggest using VBA commands instead. Here's a sample:
    <pre>Sub Test_InsertCaption()
    SetCaptionNumberingStyle "Appendix", wdCaptionNumberStyleArabic
    With Selection
    .InsertCaption "Appendix"
    .TypeParagraph
    End With
    MsgBox "Changing Style to Uppercase Arabic"
    SetCaptionNumberingStyle "Appendix", wdCaptionNumberStyleUppercaseLetter
    With Selection
    .InsertCaption "Appendix"
    .TypeParagraph
    End With
    End Sub

    Sub SetCaptionNumberingStyle(strLabel As String, _
    lngStyle As WdCaptionNumberStyle, _
    Optional blnInclChapter As Boolean = False, _
    Optional lngChapHeadingLevel As Long = 1, _
    Optional lngChapSeparator As WdSeparatorType = wdSeparatorHyphen)
    Dim capTarget As CaptionLabel
    On Error Resume Next
    Set capTarget = CaptionLabels(strLabel)
    If Err.Number = 5941 Then
    Err.Clear
    Set capTarget = CaptionLabels.Add(strLabel)
    End If
    On Error GoTo 0
    With capTarget
    .NumberStyle = lngStyle
    .IncludeChapterNumber = blnInclChapter
    If .IncludeChapterNumber = True Then
    .ChapterStyleLevel = lngChapHeadingLevel
    .Separator = lngChapSeparator
    End If
    End With
    If Not (capTarget Is Nothing) Then Set capTarget = Nothing
    End Sub</pre>

    I created a subprocedure to handle the dirtywork of adding a Caption Label if needed and assigning the numbering style, but you can do it in your main procedure if you like.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Change Caption Numbering Style (Word 2000/Windows 2000)

    I just re-read your post:

    > I am trying to find an easy method of changing the number formt for captions without having to
    > parse through every caption field.

    Can you explain this in more detail?

  4. #4
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Change Caption Numbering Style (Word 2000/Windows 2000)

    Hi Jefferson,

    I've been swamped with work and could not respond yesterday. I was trying to find a method of changing all my existing Appendix caption labels to a number or letter. I just assumed that I would have to use the Dialog object because I did not want to insert a new caption just to get my existing captions to change their number format and I thought if I did it through VBA that it would only change the number format of a newly inserted Appendix caption label. I used your code and commented out the 'selection.type paragraph' and it works great. Thanks so much.

  5. #5
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Change Caption Numbering Style (Word 2000/Windows 2000)

    Correcton - This is what I commented out:

    With Selection
    .InsertCaption "Appendix"
    .TypeParagraph
    End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •