So habe ich nach dem Erstellen einer Tabelle eine Spalte von Ja, Nein und N/A, die grün für Ja, Rot für Nein und grau für N sein muss /EIN. Nicht die ganze Reihe nur die Spalte.Suchen Sie nach bestimmten Text in Powerpoint-Tabelle von VBA erstellt von Access
Ich bin kein Anfänger, aber ich bin kein Experte bei Codierung ... hier ist mein Code:
With .Shapes.AddTable(5, 5, 0, 140, 720, 40)
' NumRows/NumColumns/Left/Top/Width/Height
.Table.ApplyStyle "{5940675A-B579-460E-94D1-54222C63F5DA}"
' Table Style for No Style, Table Grid
.Table.Cell(1, 1).Shape.TextFrame.TextRange.Text = "Text1"
.Table.Cell(1, 2).Shape.TextFrame.TextRange.Text = "TeXT2"
.Table.Cell(1, 3).Shape.TextFrame.TextRange.Text = "Text3"
.Table.Cell(1, 4).Shape.TextFrame.TextRange.Text = "Text4"
.Table.Cell(1, 5).Shape.TextFrame.TextRange.Text = "Text5"
R = 1
With .Table
For C = 1 To 5
.Cell(R, C).Shape.TextFrame.TextRange.Font.Size = 8
.Cell(R, C).Shape.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
.Cell(R, C).Shape.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
Next
R = R + 1
End With
.Table.Columns(1).Width = 140
.Table.Columns(2).Width = 60
.Table.Columns(3).Width = 60
.Table.Columns(4).Width = 100
.Table.Columns(5).Width = 360
.Fill.BackColor.RGB = RGB(255, 255, 255)
For Each cl In .Table.Rows(1).Cells
cl.Shape.Fill.BackColor.RGB = RGB(0, 32, 96)
cl.Shape.Fill.ForeColor.RGB = RGB(0, 32, 96)
cl.Shape.TextFrame.TextRange.Characters.Font.Bold = True
cl.Shape.TextFrame.VerticalAnchor = msoAnchorBottom
Next cl
' Adding data to table ------------------------
R = 2
With .Table
While Not rs26.EOF
For C = 1 To 5
.Cell(R, C).Shape.TextFrame.TextRange.Text = Nz(rs26.Fields(C - 1))
.Cell(R, C).Shape.TextFrame.TextRange.Font.Size = 8
.Cell(R, C).Shape.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft
Next 'c column
rs26.MoveNext
R = R + 1
Wend
rs26.Close
End With
' Having trouble getting this part of the code to work ------------------
With .Table
If .Cell(R, 2).Shape.TextFrame.TextRange.Text = "No" Then
.Cell(R, 2).Shape.Fill.BackColor.RGB = RGB(255, 0, 0) ' Red
.Cell(R, 2).Shape.Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf .Cell(R, 2).Shape.TextFrame.TextRange.Text = "Yes" Then
.Cell(R, 2).Shape.Fill.BackColor.RGB = RGB(146, 208, 80) ' Green
.Cell(R, 2).Shape.Fill.ForeColor.RGB = RGB(146, 208, 80)
Else
.Cell(R, 2).Shape.Fill.BackColor.RGB = RGB(166, 166, 166) ' Gray
.Cell(R, 2).Shape.Fill.ForeColor.RGB = RGB(166, 166, 166)
End If
End With
End With ' table for chart
ich über dem Code eine Kommentarzeile habe ich ein Problem habe mit . Wenn es zu diesem Teil des Codes kommt, hört es auf zu laufen.
Ich habe versucht, diesen Teil des Codes an mehreren verschiedenen Stellen, aber immer noch nicht funktionieren.
Ich hoffe, ich habe genug Informationen gegeben, damit jemand hilft.
Danke für Ihre Zeit.