Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2003
    Location
    Kansas City, Missouri
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a style array

    Wow, I've been gone for a few months, and I find a whole new BBS.

    Anyway, it's been a while since I've looked at Word VBA, and now I have an issue.

    In short, I am performing actions against any occurrences of a heading style. Furthermore, I am going to have an input box (or form with a drop down box) where the user can have the tasks performed on other styles as well. I thought that a dynamic array might be the best method for this.

    However, I am having formatting issues in the code. I have below a very small sample of what I'm working with. The array and para object are already defined.

    Set styTempStyle(1) = docCurrent.Styles("TOC 1")
    Select Case para.Range.Style
    Case docCurrent.Styles(wdStyleHeading1), _
    docCurrent.Styles(wdStyleHeading2), _
    docCurrent.Styles(wdStyleHeading3), _
    docCurrent.Styles(wdStyleHeading4), _
    docCurrent.Styles(wdStyleHeading5), _
    docCurrent.Styles(wdStyleHeading6), _
    docCurrent.Styles(wdStyleHeading7), _
    docCurrent.Styles(wdStyleHeading8), _
    docCurrent.Styles(wdStyleHeading9), _
    styTempStyle(1)


    The error occurs when trying to define the first style in the array. How do I assign a specific style to an array?

    I'm coding this in Word 97, so I cannot use exclusive Word 2000 commands.

    I appreciate any help.

    Kevin

  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: Creating a style array

    > How do I assign a specific style to an array?

    I don't quite get the whole picture...
    * Are you getting a specific error message?
    * How are you redimensioning the dynarray?
    ...but maybe I don't need to?

    How about myArray(intCounter) = para.Range.Style ?

  3. #3
    Star Lounger
    Join Date
    Apr 2003
    Location
    Kansas City, Missouri
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Okay, new question: Arrays in Case statements

    *bangs head against desk*
    Okay, *now* my code works. I'm not sure what is different, but I do that a lot.

    So, since that obstacle is, um, overcome, I have another question. Is there a way to use a Case statement to check for the elements in an array?

    To use my style example, I want to perform actions for every paragraph that uses a heading style or a style indicated by the user.

    Is it possible to have something like:

    Select Case para.Range.Style

    Case docCurrent.Styles(wdStyleHeading1), _
    etc, _
    docCurrent.Styles(wdStyleHeading9), _
    styTempStyle(2) 'check ALL elements of this array

    Or would I be better off with the case statement looking for all heading levels and just set aside about 10 to 20 variables for the user-defined styles?

    I feel like such a newbie all over again.

    Kevin

Posting Permissions

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