Results 1 to 5 of 5

Thread: SUM (Word XP)

  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    SUM (Word XP)

    I have a Word document which is not a protected form, and cannot be a protected form. There are two tables, each of which has a column that is totaled with =SUM(Above).

    I need to get a "grand" total by adding those two SUM fields. Since they are not form fields, I can't name them. I have put bookmarks around them, called Sum1 and Sum1. But Bookmark("Sum1").Range.Text always returns a whole number, even when there is a decimal value. Obviously, this won't work.

    Is there a way that I can use VBA to add two sums in a Word document?

    Thanks, Richard Barrett

  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: SUM (Word XP)

    That's strange. Perhaps you want to refer to the .Result property of the field inside the bookmark? See attached for a "long way" -- I didn't try to streamline the code, just stopped when I got the right answer.

    ActiveDocument.Bookmarks.Item("Sum1").Range.Fields (1).Result.Text
    Attached Files Attached Files

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: SUM (Word XP)

    Of course... thanks very much. I didn't think to use the Result property for a field that's not a "form" field, but this does the job. I appreciate your help.

    Richard

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

    Re: SUM (Word XP)

    Hi Richard,

    You can do this without vba too. Formula fields with the appropriate formatting (numeric picture switches) will do. Check out <post#=365442>post 365442</post#> for the details.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: SUM (Word XP)

    Thank you very much. I learned a lot from this. Richard

Posting Permissions

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