Wrox Programmer Forums
|
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 20th, 2009, 10:02 AM
Registered User
 
Join Date: Jul 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default How to get the purpose

I have a table in the word, two columns. The first column is intend to input value, the second column is limit.

I want to get the below purpose, how to get through VBA?

If the first column value is great than second column, the first column color of value is red, or not black.

thanks you in advance.
 
Old July 20th, 2009, 10:05 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Martin

Here is a hint:

Code:
Sub Color_Table()
Dim oTab As Table
Dim sCol1 As String
Dim sCol2 As String
Set oTab = ActiveDocument.Tables(1)
For i1 = 1 To oTab.Rows.Count
    sCol1 = oTab.Cell(i1, 1).Range.Text
    sCol2 = oTab.Cell(i1, 2).Range.Text
    If Val(sCol1) > Val(sCol2) Then
        oTab.Cell(i1, 1).Range.Font.ColorIndex = wdRed
    End If
Next i1

End Sub
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
The Following 2 Users Say Thank You to Shasur For This Useful Post:
Martin.wang (July 21st, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
purpose of the tooltip text Cyber Shiva HTML Code Clinic 1 September 17th, 2007 12:46 PM
Datagridview for input purpose rhd110 General .NET 0 April 18th, 2007 07:15 AM
What's The Purpose? Ben Horne Forum and Wrox.com Feedback 2 February 18th, 2004 01:13 AM
Purpose of BizObject in Core? SBurton BOOK: ASP.NET Website Programming Problem-Design-Solution 1 August 6th, 2003 07:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.