Sub ImportovatTextAZalozitSnimky()
    Dim fso As Object ' FileSystemObject
    Dim txtFile As Object ' TextStream
    Dim filePath As String
    Dim pptSlide As Slide
    Dim slideIndex As Integer
    Dim lineText As String
    
    ' Cesta k souboru
    filePath = "C:\Users\Uivatel\Documents\BakalarskaPraceCviceni\cviceni9\text.txt"
    
    ' Inicializace FileSystemObject
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    ' Oteven souboru pro ten
    If fso.FileExists(filePath) Then
        Set txtFile = fso.OpenTextFile(filePath, 1) ' 1 = ForReading
        
        ' ten souboru dek po dku
        Do Until txtFile.AtEndOfStream
            lineText = txtFile.ReadLine
            slideIndex = ActivePresentation.Slides.Count + 1
            
            ' Pidn novho snmku
            Set pptSlide = ActivePresentation.Slides.Add(slideIndex, ppLayoutText)
            pptSlide.Shapes(1).TextFrame.TextRange.Text = lineText
            
            ' Pokud je snmek sud, nastav erven pozad
            If slideIndex Mod 2 = 0 Then
                pptSlide.FollowMasterBackground = msoFalse
                pptSlide.Background.Fill.ForeColor.RGB = RGB(255, 0, 0) ' erven barva
            End If
        Loop
        
        ' Zaven souboru
        txtFile.Close
    Else
        MsgBox "Soubor nebyl nalezen!", vbExclamation
        Exit Sub
    End If

    ' Uvolnn objekt
    Set txtFile = Nothing
    Set fso = Nothing

    MsgBox "Snmky byly spn vytvoeny!", vbInformation
End Sub

