View Single Post
 
Old 02-11-2024, 11:02 PM
Aengus345 Aengus345 is offline Windows 10 Office 97-2003
Novice
 
Join Date: Feb 2024
Posts: 2
Aengus345 is on a distinguished road
Question 1. Apply to current row. 2. De-select row afterwards.

Hello! New to the forum. Thank you!

I have been trying to finish the macro as seen below. However, the last 2 things I just can't seem to figure out.

Code:
Sub TblCellShadeOf_TEN_Percent()
'
' ------------------------------------
    Dim tbl As table
    Set tbl = ActiveDocument.Tables(1)
    tbl.Rows(6).Select
' ------------------------------------
    
    With Selection.Cells
        With .Shading
             .Texture = wdTextureNone
             .ForegroundPatternColor = wdColorAutomatic
             .BackgroundPatternColor = wdColorGray10
        End With
    End With
End Sub
1. I can't figure out how to change syntax of [tbl.Rows(6).Select] to just something that represents the CURRENT ROW (the one the cursor is on). This code, tbl.Rows(6).Select, does work on this particular table, but it won't work if the table row changes location. I'd rather just use something that represents the current row.

2. How to de-select the row after the shading is applied. Once the shading is done, the row _is_ shaded, but I'd rather the current row have the 10% shading applied without showing it still selected in the end. I'm sure it's represented by something in the code above, but I'm not very good at vba, so can't figure out what code does that (I know, I know ... dumb ...

Thank you very much in advance for any help in this regard!

Reply With Quote