View Single Post
 
Old 09-25-2021, 08:30 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default Help, IF with 2 Conditions, Then, Else, only works if I have 1 condition

Hello Pros,
I'm pretty proud of myself, to figured out how to have Row 1 if the Font color is DarkRed, for example, to put Row(1) as Text.

It works, I've tested it on tables with multiple rows, having DarkRed on Row 1 and other tables having it a blue for instance, on Row 1.
And some single Table Row being either DarkRed and others being Blue.

What I'm having an issue, is trying to find Font Color DarkRed AND Font being Bold.

As you can see with the single quote, ' , which is considered Text (in VBA, it would show in Green), I'm just trying to show i've tried many ways, it didn't work.

Code:
Sub TBL_to_Txt_if_Row1_is_DarkRed()

Application.ScreenUpdating = False
    
    Dim aTbl As Table, aRow As Row
    Dim rg As range

    For Each aTbl In ActiveDocument.Tables
      With aTbl
       '.Rows(1).range.Font.Color = wdColorOrange / wdColorDarkRed
       '.Rows(1).range.Font.Color = 192
       '.Rows(1).range.Rows.Select
         
        'Selection.SplitTable
     'End With
      
       'If (aTbl.Rows(1).range.Font.Color = 192) + (aTbl.Rows(1).range.Font.Bold = True) Then
       'If (aTbl.Rows(1).range.Font.Bold) + (aTbl.Rows(1).range.Font.ColorIndex = 192) = True Then
        If aTbl.Rows(1).range.Font.Color = 192 = True Then
        
    .Rows(1).ConvertToText Separator:=wdSeparateByParagraphs, _
        NestedTables:=False
        
        Else
        
        End If
      
      End With
    Next
    
Application.ScreenUpdating = True
  On Error GoTo 0
  
lbl_Exit:
  Exit Sub

End Sub
Any insights would be soooooo appreciated.

Thanking you in advance

Cendrinne
Reply With Quote