+ Reply to Thread
Results 1 to 4 of 4

vba code for math in a word table

  1. #1
    Registered User
    Join Date
    02-02-2012
    Location
    Austin, Texas
    MS-Off Ver
    Office 365
    Posts
    33

    vba code for math in a word table

    Afternoon all,

    I am seeking the aid of someone far more familiar with vba for word than I am as I am a relative newbie on the word side. I have a document (attached) that has a table that i need to perform some mathematical computations on. I can't seem to get the proper sequesnce of code to do what I need it to do. I cannot insert an excel object as the external users do not have access to our file server. Any assistnace offerd will be greatly appreciated
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: vba code for math in a word table

    Maybe you could try just using a Word formula

    e.g.

    =SUM(A2,PRODUCT(-1,A4))

    in Cell A6.

    The formula button is on the Layout ribbon when the table is selected.
    Martin

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: vba code for math in a word table

    Hi Kelwood,

    Some comments:
    1. Re: "I cannot insert an excel object as the external users do not have access to our file server"
    That's irrelevant - all they need to have is Excel on their own PCs.
    2. Re: vba
    You can use formula fields instead for the calculations. This has none of the vba security issues and, depending on whether you can use formfields and forms protection, can be configured to do the calculations automatically. For example, formula fields for A6 & G2 could be {=A2-A4 \# 0} and {=-((F2*B2)-(A6/6000)*(D2-E2)) \# 0}, respectively, where the field braces (ie {}) are created via Ctrl-F9.
    3. Re: Your formulae
    Word cell referencing is always absolute and doesn't use $ symbols for that. For G2, G3 & G4 your formulae all reference column B, which contains text! Word is no better at multiplying text by numbers (eg F2*B2) than Excel, so all results will be 0.

    Notwithstanding the qualifications re column B, I've added the necessary formula fields to your document. See attached. After updating the various cells, select the table and press F9 to update the calculations.
    Attached Files Attached Files
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Registered User
    Join Date
    02-02-2012
    Location
    Austin, Texas
    MS-Off Ver
    Office 365
    Posts
    33

    Re: vba code for math in a word table

    Thanks for your work Paul but the department chair has moved us in a different direction and created a new challenge.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1