Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Nov 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Insert a field (Word 2000 /XP)

    Hello:
    I would like to be able to insert "fields" that will be associated with a custom formula - in a way a cell without a table - so the value in that field will be recalculated every when the field is accessed. The "fields" would be inserted at the cursor position anywhere in a Word document
    (including tables) and they must react to any change in the data.
    Any ideas how can I approach this?
    Thanks,
    Mihail

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert a field (Word 2000 /XP)

    Hi Mihail:
    If you have a protected form, you can have a form field property set to "calculate on exit". This will calculate whenever the user leaves that field. You can have a REF field (that refers to that specific formfield) set up as an AutoText entry. Then a user could type the autotext name & press F3 to insert the REF field, provided you were in a non-protected section of the document.

    If your needs are different, one of the VBA experts may have an idea.
    Cheers,

  3. #3
    New Lounger
    Join Date
    Nov 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert a field (Word 2000 /XP)

    Hi Phil,
    Thanks for you answer. I need to be more specific - the "fields" that I want to insert will need to by dynamic, the user will insert that field via a right click menu that will take him to a dialogue where all the values of the formulas
    will be set. Based on these values the dialog will return a string with a formula that needs to be evaluated afterwards. So most likely I will need to do this via VBA. Sorry for any confusion - I am kind of fuzzy with form and form fields - can these form fields be inserted in a document (not a protect form)?
    In a way my stuff should work similar with Excel cells but maybe these calculated fields will do it if I can link the formulas to them and then dropped at the cursor the result of my calculations.
    Mihail

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert a field (Word 2000 /XP)

    Hi Mihail:
    I'm afraid one of the VBA experts will have to help, as I'm not an expert in that area or on userforms. Form fields can be inserted into a document, but really have little use unless the document is protected. If the document isn't protected, then selecting the form field & typing will overwrite the form. Sorry I can't be of further help here. Hopefully, one of the VBA experts can.

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Insert a field (Word 2000 /XP)

    What we have done in similar circumstances is to use Document Variables.

    We provide the user with a form that enables them to change the values of the variables. This form also has a section that allows them to insert the { Docvar xxx } field in the document. Closing the form causes an immediate update of all fields in the document to ensure that a change to a value gets propagated correctly.

    StuartR

  6. #6
    New Lounger
    Join Date
    Nov 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Insert a field (Word 2000 /XP)

    Hi StuartR:
    Thank you for your answer. Are you saying that I should store the formula in each variable that I will add to the variable collection and recalculate them at exit/open by looping through all of them? Is there a way to recalculate the variable filed when you hit the filed in the document? What about trying to reinsert in a filed already existing as a variable field - is there a way to check in VBA - this field at this position is a variable field with the name of - so I don't need to insert a new one just change the existent one value? Any explanation (example) would help a lot.
    Mihail

  7. #7
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Insert a field (Word 2000 /XP)

    Hi Mihail,

    One way of getting a formula to update immediately as a result of a change to its variables is to embed the lot in a QUOTE field. For example:
    {QUOTE{ASK VAR1 "Variable 1"}{ASK VAR2 "Variable 2"}{ASK VAR3 "Variable 3"}{SET Result{=(VAR1+VAR2)/VAR3 # 0.000}{Result}}
    In this case there are three variables (VAR1, VAR2, VAR3) for which the formula is =(VAR1+VAR2)/VAR3. When the field is updated, the user is asked to supply the three variables and, once that is done, the result is automatically calculated and displayed (in this case to three decimal places via the numeric picture switch).
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. #8
    Lounger
    Join Date
    Feb 2003
    Location
    Renfrewshire, Scotland
    Posts
    35
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Insert a field (Word 2000 /XP)

    Hi all,
    I have a similar problem to Mihail in that I'm using version numbers to keep track of a particular document. The problem is I want to see the version number displayed in a footer and ideally a document variable field would do the trick. Unfortunately version numbers (Word 2000) isn't available as a variable!. I've got round it using vba (ActiveDocument.Versions.Count) but of course this is in an autorun macro which for obvious reasons I'd prefer not to use. Does anyone know a method of creating your own document variables or is there an "undocumented" workaround?

Posting Permissions

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