Sub sestav_vysledne_tabulky()
Dim hodnot(100, 3)
i = 1
' Nalezeni tabulky ve zprave ********************************************************************
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Poř.^pčís." ' Hledany text
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
index_tab = ActiveDocument.Range(0, Selection.Tables(1).Range.End).Tables.Count
poc_rad = ActiveDocument.Tables(index_tab).Rows.Count
For k = 2 To poc_rad
hodnoceni = ""
On Error Resume Next
hodnoceni = odstran_spatne_znaky(ActiveDocument.Tables(index_tab).Cell(k, 5).Range.Text)
On Error GoTo 0
If hodnoceni <> "" Then
If hodnoceni = "2" Or hodnoceni = "3" Then
hodnot(i, 1) = odstran_spatne_znaky(ActiveDocument.Tables(index_tab).Cell(k, 1).Range.Text)
temp = odstran_spatne_znaky(ActiveDocument.Tables(index_tab).Cell(k, 4).Range.Text)
hodnot(i, 2) = dalsi_uprava_formatu(temp)
hodnot(i, 3) = hodnoceni
i = i + 1
End If
End If
Next k
'For k = 1 To i - 1: MsgBox hodnot(k, 3) & " ... " & hodnot(k, 1) & " ... " & hodnot(k, 2): Next k
' odstraneni vsech radku v tabulce neshod - az na 1. a 2. radek
For t = 1 To 2
With ActiveDocument.Tables(index_tab + t)
NumRows = .Rows.Count
For m = NumRows To 3 Step -1: .Rows(m).Delete: Next m
If NumRows >= 2 Then
.Cell(2, 1).Range.Text = "": .Cell(2, 2).Range.Text = ""
Else
ActiveDocument.Tables(index_tab + t).Rows.Add
.Cell(2, 1).Shading.BackgroundPatternColor = wdColorAutomatic
.Cell(2, 2).Shading.BackgroundPatternColor = wdColorAutomatic
.Cell(2, 2).Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
End If
End With
Next t
' zlute neshody
rad_vypis = 2
With ActiveDocument.Tables(index_tab + 1)
For q = 1 To i - 1
If hodnot(q, 3) = 2 Then
If rad_vypis > 2 Then .Rows.Add
.Cell(rad_vypis, 1).Range.Text = hodnot(q, 1): .Cell(rad_vypis, 2).Range.Text = hodnot(q, 2)
rad_vypis = rad_vypis + 1
End If
Next q
End With
' cervene neshody
rad_vypis = 2
With ActiveDocument.Tables(index_tab + 2)
For q = 1 To i - 1
If hodnot(q, 3) = 3 Then
If rad_vypis > 2 Then .Rows.Add
.Cell(rad_vypis, 1).Range.Text = hodnot(q, 1): .Cell(rad_vypis, 2).Range.Text = hodnot(q, 2)
rad_vypis = rad_vypis + 1
End If
Next q
End With
skoc_na_tab_neshod ' PONECHAT ??????????????????????????????????????????????????????????????????????
End Sub
Toto je vysledne reseni, ja to jsem i schopen dat dohromady, jenze me vzdy silene tlaci cas!!! U nas musi byt vse hned, no... Takze sned take konecne necim prispeji ja...
|