Jump to content

Recommended Posts

Posted
I don't think you can do this in Word. If your values are changing, so that you want the formatting to update too, perhaps you could prepare your table in Excel and link the table to display it in Word?
Posted

Yes, it is an individual report from SIMS so it has to be in word, as far as im aware! I got a VB script to look at the column that i want, and select it, but i do not know how to make it look at the data. One would have thought it would be an IF statement of some kind.

But i am no VB Scripter and could be talking utter rubbish!!!

Posted

Try this...it's Word 2003 but should work for later versions...

Public Sub highlighter()

Dim obj As Table


Set obj = ActiveDocument.Tables(1)


For x = 1 To obj.Rows.Count
   If Val(obj.Rows(x).Cells(7).Range.Text) < 3 Then
       obj.Rows(x).Shading.BackgroundPatternColor = wdColorGray20
   End If
Next


End Sub

Posted

That seems to Highlight the whole thing....

 

Attached is the table, i need it to automatically highlight a row that contains a Y in Concern column. I cannot do this in Excel as it is an Individual Report from SIMS and as far as im aware you cannot change the output of a Individual Report to Excel.

Any help would be much appreciated.

 

Table1.doc

Posted

You just needed to change the cell references and the value check to match your data...

Try this

Public Sub highlighter()

Dim obj As Word.Table
Dim x As Integer


Set obj = ActiveDocument.Tables(1)


For x = 1 To obj.Rows.Count
   If Left(obj.Rows(x).Cells(4).Range.Text, 1) = "Y" Then
       obj.Rows(x).Shading.BackgroundPatternColor = wdColorGray20
   End If
Next


End Sub


  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...