Increment Bookmark name?

Discussion in 'Word VBA Beginners' started by Basalt, Apr 30, 2011.

  1. Basalt

    Basalt Guest

    I have an english and a spanish version of a word form. I have created
    a macro to check the corresponding box in spanish when the english box
    is checked. However, the bookmark name is hardcoded in the macro so
    the macro only works on the first box of each version - checkbox1 and
    checkbox76. Is there a way for me to have the macro increment the
    bookmark name so it correctly marks the checkbox? Such as:

    {checkboxname}
    {checkboxname} + 75

    or some better way?

    Thanks!
    Jason
     
    Basalt, Apr 30, 2011
    #1
    1. Advertisements

  2. Basalt

    Jay Freedman Guest

    On Fri, 29 Apr 2011 16:31:26 -0700 (PDT), Basalt <> wrote:

    >I have an english and a spanish version of a word form. I have created
    >a macro to check the corresponding box in spanish when the english box
    >is checked. However, the bookmark name is hardcoded in the macro so
    >the macro only works on the first box of each version - checkbox1 and
    >checkbox76. Is there a way for me to have the macro increment the
    >bookmark name so it correctly marks the checkbox? Such as:
    >
    >{checkboxname}
    >{checkboxname} + 75
    >
    >or some better way?
    >
    >Thanks!
    >Jason


    You can do something like this:

    For i = 1 To 75
    englishCheckboxName = "checkbox" & i
    spanishCheckboxName = "checkbox" & (i + 75)

    ActiveDocument.FormFields(spanishCheckboxName).Result = _
    ActiveDocument.FormFields(englishCheckboxName).Result
    Next i
     
    Jay Freedman, May 2, 2011
    #2
    1. Advertisements

  3. Basalt

    Basalt Guest

    On May 1, 8:43 pm, Jay Freedman <> wrote:
    > On Fri, 29 Apr 2011 16:31:26 -0700 (PDT), Basalt <> wrote:
    > >I have an english and a spanish version of a word form. I have created
    > >a macro to check the corresponding box in spanish when the english box
    > >is checked. However, the bookmark name is hardcoded in the macro so
    > >the macro only works on the first box of each version - checkbox1 and
    > >checkbox76. Is there a way for me to have the macro increment the
    > >bookmark name so it correctly marks the checkbox? Such as:

    >
    > >{checkboxname}
    > >{checkboxname} + 75

    >
    > >or some better way?

    >
    > >Thanks!
    > >Jason

    >
    > You can do something like this:
    >
    > For i = 1 To 75
    >    englishCheckboxName = "checkbox" & i
    >    spanishCheckboxName = "checkbox" & (i + 75)
    >
    >    ActiveDocument.FormFields(spanishCheckboxName).Result = _
    >       ActiveDocument.FormFields(englishCheckboxName).Result
    > Next i


    Thanks!
     
    Basalt, May 2, 2011
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. kph
    Replies:
    1
    Views:
    144
    Doug Robbins - Word MVP
    Aug 5, 2003
  2. George Seese

    Change Bookmark Range Font

    George Seese, Aug 10, 2003, in forum: Word VBA Beginners
    Replies:
    5
    Views:
    415
    Dave Lett
    Aug 12, 2003
  3. Nancy D.

    Text box and bookmark

    Nancy D., Oct 6, 2003, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    136
    Cindy Meister -WordMVP-
    Oct 7, 2003
  4. John Shanley

    Problem Replacing Bookmark content

    John Shanley, Oct 19, 2003, in forum: Word VBA Beginners
    Replies:
    4
    Views:
    233
    Jay Freedman
    Oct 23, 2003
  5. VK

    How to insert text into bookmark

    VK, Oct 26, 2003, in forum: Word VBA Beginners
    Replies:
    2
    Views:
    127
  6. Rick

    Making bookmark uneditable by user

    Rick, Nov 10, 2003, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    141
    Word Heretic
    Nov 11, 2003
  7. text news

    How can I increment filenames

    text news, Feb 3, 2004, in forum: Word VBA Beginners
    Replies:
    2
    Views:
    126
    text news
    Feb 3, 2004
  8. Fernando Peralta

    tables.cell string used as bookmark name

    Fernando Peralta, Aug 24, 2004, in forum: Word VBA Beginners
    Replies:
    3
    Views:
    109
    Fernando Peralta
    Aug 25, 2004
Loading...