Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Apr 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CommandButton resets values of public variables (Word 2003)

    I have a Word 2003 template which is a form. Users use the template to open a blank form.

    The form has a number of formfields and (activex) commandbuttons. It also has two public variables, the values of which need to be available to the Click event procedures that are invoked by the commandbuttons.

    However, when users click on any of the buttons, all the public variables are reset to their default values, losing the values set in other procedures.

    Can anyone help me debug this ?

    Thanks

    Garry
    <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: CommandButton resets values of public variables (Word 2003)

    We'll need detailed information:
    - How are the public variables set, and when?
    - How do the command buttons use the public variables?
    - What other code do the command buttons run?

    Could you attach a zipped copy of the template? You can strip out most of the contents, leave just enough to demonstrate the problem. Remove or alter sensitive/proprietary information.

  3. #3
    Lounger
    Join Date
    Apr 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CommandButton resets values of public variables (Word 2003)

    Hello,

    The public variables are set at the module level.
    The command buttons invoke private code on the Click event. I had hoped that the public variables would be available but they're not.
    The buttons run code to add/remove additional sections to the form.

    I found a solution by creating variables that are stored in the file (ie. ActiveDocument.Variables.Add). I store the values I want in those variables and get their values inside the Command button code. It's crude but it now works.

    Many thanks.


    Garry
    <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

Posting Permissions

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