• Conditionally format table cells when field result = 0

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Conditionally format table cells when field result = 0

    Author
    Topic
    #461939

    Hi everybody:

    I’ve inherited a template with a Word 2003 table that serves as an order form. The user types in the number and price of items to order and the table fields compute sales tax, add in the shipping costs, and produces a grand total. The last column of each row contains fields to multiply the number of items by their cost, and the bottom rows sum things up. The results are formatted as currency. Fine.

    I put a button on the Grand Total cell for the user to update all the fields before printing or emailing the form, since Word doesn’t do that automatically.

    Now, my boss wants not to see the $0.00 amounts that show up in the last column of each row when an order has not been entered on that row. So, I’d like to conditionally format these cells. My thought was to add some simple code to the Total button that when looping through the fields to update them would also set their cell fonts to white if their result = 0, black otherwise. Can’t find in the Word object model a way to get the cell references for a field in a table.

    Thank you, in advance, for your help.

    Kathryn

    Viewing 1 reply thread
    Author
    Replies
    • #1173910

      If you have a field fld, you can use fld.Result to return the range of that field, or if you prefer the entire cell, you can use fld.Result.Cells(1).Range

      For example:

      fld.Result.Cells(1).Range.Font.Color = wdColorWhite

    • #1173915

      Thanks, Hans! I knew you would know.

    Viewing 1 reply thread
    Reply To: Conditionally format table cells when field result = 0

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: