{"text_format":"1","workbook":"xlsx","n_sheets":8,"sheets":["Úvod","Teorie","Zprovoznění","Existuje","Tvorba","Mazání","Kopie - presouvání","Ostatní-Poznámky"],"not_rendered":{"charts":0,"images":18,"macros":1,"external_links":0,"defined_names":0,"comments":0,"pivot_tables":0},"unopened":[],"bounds":{"document_bytes":16777216,"sheet_cells":100000,"rows_first":2000,"rows_last":500,"rows_between":2000,"halvings":0,"cell_chars":16384,"cell_head_chars":4096},"cells_cut":0,"cells_raw":0,"read":"whole","date_system":"1900"}

{"sheet":"Úvod","index":0,"n_rows":29,"n_cols":8,"rows_kept":29,"cut":false,"hidden":false,"merged":[[28,1,28,11],[1,2,1,9],[13,2,14,6],[16,3,17,6],[17,7,17,9],[6,7,6,8],[5,7,5,8]]}
[]
[null,null,"Jak na Excel - VBA"]
[]
[]
[null,null,null,"Obsah cvičení"]
[null,null,null,null,"FileSystemObject - Teorie a zprovoznení",null,null,"FileSystemObject"]
[null,null,null,null,"Existuje atd. zjišťování stavu",null,null,"FSO"]
[null,null,null,null,"Tvorba Souboru"]
[null,null,null,null,"Mazání souboru"]
[null,null,null,null,"Kopie souboru (složek)"]
[]
[]
[]
[null,null,"Pavel Lasák"]
[]
[]
[null,null,null,"Lektor, expert na Microsoft Excel, držitel prestižního ocenění Microsoftu MVP v České republice"]
[null,null,null,null,null,null,null,5002722]
[]
[]
[]
[]
[null,null,null,"Další informace ke cvičení:"]
[null,null,null,null,"https://office.lasakovi.com/excel/vba-soubory/FileSystemObject-VBA-Excel/"]
[]
[]
[]
[]
[null,"Copyright, Pavel Lasák 2019, rev 2021"]

{"sheet":"Teorie","index":1,"n_rows":48,"n_cols":8,"rows_kept":48,"cut":false,"hidden":false,"merged":[[44,4,47,4],[0,0,0,2],[14,4,16,4],[19,4,26,4],[29,4,41,4],[1,0,1,2]]}
["FileSystemObject ve  VBA"]
["https://office.laskovi.com/"]
[]
[null,"Teorie"]
[]
[null,"Kontrola existence souboru"]
[null,"Vytváření, úprava a mazání složek."]
[null,"Otvírání, čtení, vytváření a mazání textových souborů."]
[null,"Kopírování a přesouvání souborů nebo složek."]
[]
[]
[null,"Objekt","Popis objektu"]
[null,"Disk ","pro získání informace o diskové jednotce (prostor, který je k dispozici, její logický název, atd.) Tip může jít i o FlashDisk, CD-ROM, nebo disk připojení přes LAN…."]
[null,"Složka","umožňuje vytvářet, přesouvat, mazat v adresářích (složkách)",null,null,"Metoda ","Popis","Kód"]
[null,"Soubor","umožňuje vytvořit, přesunout, smazat soubor.",null,"Disk","GetDrive","Tyto metody se používají pro načítání informací o jednotkách, složkách a souborech."]
[null,"TextStream","umožňuje číst nebo zapisovat do textových souborů",null,null,"DriveExists","Kontrola zda disk existuje"]
[null,null,null,null,null,"GetDriveName","Vrací jméno disku","fso.GetDriveName( path )"]
[]
[]
[null,null,null,null,"Disk","GetFolder","Tyto metody se používají pro načítání informací o jednotkách, složkách a souborech."]
[null,null,null,null,null,"CopyFolder"," Tyto metody pomáhají při kopírování souborů nebo složek z jednoho umístění do druhého."]
[null,null,null,null,null,"CreateFolder","Pomáhá při vytváření nových složek. "]
[null,null,null,null,null,"DeleteFolder","Odstraňování ukončených složek."]
[null,null,null,null,null,"FolderExists","Checks whether the Folder exists or not"]
[null,null,null,null,null,"MoveFolder","Tyto metody pomáhají při přesunu souborů nebo složek z jednoho umístění do druhého."]
[null,null,null,null,null,"GetParentFolderName","Retruns the name of the parent folder based on the specified path"]
[null,null,null,null,null,"GetSpecialFolder","Get the location of various system folders."]
[]
[]
[null,null,null,null,"Soubor","GetFile","Tyto metody se používají pro načítání informací o jednotkách, složkách a souborech."]
[null,null,null,null,null,"CreateTextFile","Pomáhá při vytváření nových souborů."]
[null,null,null,null,null,"DeleteFile"," Pomáhá při odstraňování ukončených souborů nebo složek."]
[null,null,null,null,null,"CopyFile"]
[null,null,null,null,null,"MoveFile","Tyto metody pomáhají při přesunu souborů nebo složek z jednoho umístění do druhého."]
[null,null,null,null,null,"DeleteFile","Deletes a file"]
[null,null,null,null,null,"FileExists","Checks if a file exists or not"]
[null,null,null,null,null,"GetExtensionName","Returns the file extension"]
[null,null,null,null,null,"GetFileName","Returns the file name"]
[null,null,null,null,null,"GetFileVersion","Returns the file version"]
[null,null,null,null,null,"CreateTextFile","Creates a text file"]
[null,null,null,null,null,"GetStandardStream","Retrieve the standard input, output or error stream"]
[null,null,null,null,null,"OpenTextFile","Open a file as a TextStream"]
[]
[]
[null,null,null,null,"Ostatní","BuildPath","Generate a path from an existing path and a name"]
[null,null,null,null,null,"GetAbsolutePathName","Return the canonical representation of the path"]
[null,null,null,null,null,"GetBaseName","Return base name from a path. For example, “D:\\TestFolder\\TestFile.xlsm” will return TextFile.xlsm"]
[null,null,null,null,null,"GetTempName","Generate name that can be used to name a temporary file"]

{"sheet":"Zprovoznění","index":2,"n_rows":6,"n_cols":2,"rows_kept":6,"cut":false,"hidden":false,"merged":[[0,0,0,2],[1,0,1,2]]}
["FileSystemObject ve  VBA"]
["https://office.laskovi.com/"]
[]
[null,"Tools  >  Reference "]
[]
[null,"Microsoft Scripting Runtime"]

{"sheet":"Existuje","index":3,"n_rows":52,"n_cols":4,"rows_kept":52,"cut":false,"hidden":false,"merged":[[0,0,0,4],[1,0,1,2]]}
["FileSystemObject - stavy Excel VBA"]
["https://office.laskovi.com/"]
[]
[null,"Existuje složka (adresář)"]
[]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Set MyFSO = New FileSystemObject"]
[null,"If MyFSO.FolderExists(\"D:\\smaz\") Then"]
[null,"    MsgBox (\"Složka existuje.\")"]
[null,"Else"]
[null,"    MsgBox (\"Složka neexistuje.\")"]
[null,"End If"]
[]
[]
[null,"Existuje soubor"]
[]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Set MyFSO = New FileSystemObject"]
[null,"If MyFSO.FileExists(\"D: \\smaz\\test.pdf\") Then"]
[null,"    MsgBox (\"Soubor existuje.\")"]
[null,"Else"]
[null,"    MsgBox (\"Soubor neexistuje.\")"]
[null,"End If"]
[]
[]
[null,"Výpis souboru v adresáři"]
[]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Dim MyFile As File"]
[null,"Dim MyFolder As Folder"]
[]
[null,"Set MyFSO = New Scripting.FileSystemObject"]
[null,"Set MyFolder = MyFSO.GetFolder(\"D:\\smaz\")",null,"Do listu"]
[null,null,null,"i = 1"]
[null,"For Each MyFile In MyFolder.Files",null,"For Each MyFile In MyFolder.Files"]
[null,"    Debug.Print MyFile.Name",null,"    Cells(i+3,4).value =  MyFile.Name"]
[null,"Next MyFile",null,"    i = i +1"]
[null,null,null,"Next MyFile"]
[]
[]
[null,"Velikost"]
[]
[null,"Set FSO = New Scripting.FileSystemObject"]
[null,"Dim drv As Drive"]
[null,"Dim Space As Double"]
[]
[null,"Set drv = FSO.GetDrive(\"D:\")"]
[null,"Space = drv.FreeSpace"]
[null,"Space = Space / 1073741824 'na GB  "]
[null,"Space = WorksheetFunction.Round(Space, 2)"]
[null,"' Zaokrouohlení"]
[null,"MsgBox (\"D: má volných = \" & Space & \" GB\")"]

{"sheet":"Tvorba","index":4,"n_rows":82,"n_cols":7,"rows_kept":82,"cut":false,"hidden":false,"merged":[[0,0,0,4]]}
["FileSystemObject - stavy Excel VBA"]
[]
[]
[null,"Vytvořit složku"]
[]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Set MyFSO = New FileSystemObject"]
[null,"MyFSO.CreateFolder (\"D:\\smaz\\blalba\")"]
[]
[]
[]
[null,"Ošetřit pokud bude složka exisovat"]
[null,null,null,null,null,null,"Dim MyFSO As FileSystemObject"]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Set MyFSO = New FileSystemObject",null,null,null,null,"Set FSO = New Scripting.FileSystemObject"]
[null,"If MyFSO.FolderExists(\"D:\\smaz\\blalba\") Then",null,null,null,null,"Dim drv As Drive"]
[null,"    MsgBox (\"Složka existuje.\")",null,null,null,null,"Dim Space As Double"]
[null,"Else"]
[null,"    MyFSO.CreateFolder (\"D:\\smaz\\blalba\")",null,null,null,null,"Set FSO = CreateObject(\"Scripting.FileSystemObject\")"]
[null,"End If",null,null,null,null,"GetDriveName"]
[null,null,null,null,null,null,"MsgBox (FSO.GetDriveName(\"C:\\Src\"))"]
[null,null,null,null,null,null,"'Result: C:"]
[]
[null,"Vytvoř soubor prázdný"]
[]
[null,"Dim FSO As FileSystemObject"]
[null,"Set FSO = New FileSystemObject"]
[null,"Dim txtstr As TextStream"]
[null,"Dim FileName As String"]
[]
[null,"' soubor který bude vytvořen"]
[null,"FileName = \"D:\\smaz\\smaz_File_2.txt\""]
[]
[null,"' Vytvořit soubor"]
[null,"Set txtstr = FSO.CreateTextFile(FileName,  True,  True)"]
[]
[]
[null,"Vytvoř soubor a něco zapiš"]
[]
[]
[null,"Dim FSO As FileSystemObject"]
[null,"Set FSO = New FileSystemObject"]
[]
[null,"Dim txtstr As TextStream"]
[null,"Dim FileName As String"]
[null,"Dim FileContent As String"]
[null,"Dim File As File"]
[null,"' soubor který bude vytvořen"]
[null,"FileName = \"D:\\smaz\\smaz_File.txt\""]
[null,"' mužeme načíst z input box, form, buňky  "]
[null,"FileContent = \"Pokus JakNaExcel.cz\""]
[]
[null," 'Vytvořit a doplnit"]
[null," ' Tip Kontrola existence"]
[null,"Set txtstr = FSO.CreateTextFile(FileName,  True,  True)"]
[null,"    txtstr.Write FileContent"]
[null,"    txtstr.Close"]
[]
[null,"Set File = FSO.GetFile(FileName)"]
[]
[null,"Set txtstr = File.OpenAsTextStream(ForReading,  TristateUseDefault)"]
[null,"MsgBox (\"Vytvořeno: \" & FileName & \" a uloženo do souboru: \" & txtstr.ReadAll)"]
[null,"txtstr.Close"]
[]
[null,"' Pokud budu chtít smazat při testech"]
[null,"' File.Delete (True)"]
[]
[]
[]
[]
[]
[]
[]
[]
[null,"' Využitím FSO"]
[null,"   Dim fso As Object"]
[null,"    Set fso = CreateObject(\"Scripting.FileSystemObject\")"]
[]
[null,"    Dim Fileout As Object"]
[null,"    Set Fileout = fso.CreateTextFile(\"D:\\smaz\\vba.txt\", True, True)"]
[null,"    Fileout.Write \"Jak na Excel je nejlepší.\""]
[null,"    Fileout.Close"]

{"sheet":"Mazání","index":5,"n_rows":53,"n_cols":2,"rows_kept":53,"cut":false,"hidden":false,"merged":[[0,0,0,4]]}
["FileSystemObject - smazat Excel VBA"]
[]
[null,"Mazání složky"]
[]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Set MyFSO = New FileSystemObject"]
[]
[null,"MyFSO.DeleteFolder (\"D:\\smaz\\blabla\")"]
[]
[null,"Set MyFSO = Nothing"]
[]
[]
[null,"Mazání souboru"]
[]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Set MyFSO = New FileSystemObject"]
[]
[null,"MyFSO.DeleteFile (\"D:\\smaz\\test.pdf\")"]
[]
[null,"Set MyFSO = Nothing"]
[]
[]
[null,"Mazání souboru a složky jako funkce"]
[]
[null,"Function FnDeleteFile(strFileName)"]
[null,"       Set fso = CreateObject(\"Scripting.FileSystemObject\")"]
[null,"       fso. DeleteFile (strFileName)"]
[null,"End Function"]
[]
[]
[]
[]
[]
[]
[null,"K testování"]
[]
[null,"Function FnDeleteFile(strFileName)"]
[null,"       Set fso = CreateObject(\"Scripting.FileSystemObject\")"]
[null,"       fso. DeleteFile (strFileName)"]
[null,"End Function"]
[]
[null,"Dim fso as New FileSystemObject, aFile as File"]
[null,"if (fso.FileExists(\"PathToFile\")) then"]
[null,"    aFile = fso.GetFile(\"PathToFile\")"]
[null,"    aFile.Delete"]
[null,"End if"]
[]
[]
[null,"With New FileSystemObject"]
[null,"    If .FileExists(yourFilePath) Then"]
[null,"        .DeleteFile yourFilepath"]
[null,"    End If"]
[null,"End With"]

{"sheet":"Kopie - presouvání","index":6,"n_rows":81,"n_cols":2,"rows_kept":81,"cut":false,"hidden":false,"merged":[[0,0,0,3]]}
["FileSystemObject - smazat Excel VBA"]
[]
[null,"Zkopírovat soubor"]
[]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Dim SourceFile As String"]
[null,"Dim DestinationFolder As String"]
[null,"Set MyFSO = New Scripting.FileSystemObject"]
[]
[null,"SourceFile = \"D:\\smaz\\aaa\\test.pdf\""]
[null,"DestinationFolder = \"D:\\smaz\\bbb\""]
[]
[null,"MyFSO.CopyFile Source:=SourceFile, Destination:=DestinationFolder & \"\\test.pdf\""]
[]
[]
[null,"Kopírovat soubor"]
[null,"Sub CopyFile()"]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Dim SourceFile As String"]
[null,"Dim DestinationFolder As String"]
[null,"Set MyFSO = New Scripting.FileSystemObject"]
[]
[null,"SourceFile = \"C:\\Users\\sumit\\Desktop\\Source\\SampleFile.xlsx\""]
[null,"DestinationFolder = \"C:\\Users\\sumit\\Desktop\\Destination\""]
[]
[null,"MyFSO.CopyFile Source:=SourceFile, Destination:=DestinationFolder & \"\\SampleFileCopy.xlsx\""]
[]
[null,"End Sub"]
[]
[]
[]
[]
[null,"Kopírovat soubory"]
[null,"Sub CopyAllFiles()"]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Dim MyFile As File"]
[null,"Dim SourceFolder As String"]
[null,"Dim DestinationFolder As String"]
[null,"Dim MyFolder As Folder"]
[null,"Dim MySubFolder As Folder"]
[]
[null,"SourceFolder = \"C:\\Users\\sumit\\Desktop\\Source\""]
[null,"DestinationFolder = \"C:\\Users\\sumit\\Desktop\\Destination\""]
[]
[null,"Set MyFSO = New Scripting.FileSystemObject"]
[null,"Set MyFolder = MyFSO.GetFolder(SourceFolder)"]
[]
[null,"For Each MyFile In MyFolder.Files"]
[null,"    MyFSO.CopyFile Source:=MyFSO.GetFile(MyFile), _"]
[null,"    Destination:=DestinationFolder & \"\\\" & MyFile.Name, Overwritefiles:=False"]
[null,"Next MyFile"]
[]
[null,"End Sub"]
[]
[]
[]
[]
[]
[null,"Jen Excelovské soubory kopírovat"]
[null,"Sub CopyExcelFilesOnly()"]
[null,"Dim MyFSO As FileSystemObject"]
[null,"Dim MyFile As File"]
[null,"Dim SourceFolder As String"]
[null,"Dim DestinationFolder As String"]
[null,"Dim MyFolder As Folder"]
[null,"Dim MySubFolder As Folder"]
[]
[null,"SourceFolder = \"C:\\Users\\sumit\\Desktop\\Source\""]
[null,"DestinationFolder = \"C:\\Users\\sumit\\Desktop\\Destination\""]
[]
[null,"Set MyFSO = New Scripting.FileSystemObject"]
[null,"Set MyFolder = MyFSO.GetFolder(SourceFolder)"]
[]
[null,"For Each MyFile In MyFolder.Files"]
[null,"    If MyFSO.GetExtensionName(MyFile) = \"xlsx\" Then"]
[null,"        MyFSO.CopyFile Source:=MyFSO.GetFile(MyFile), _"]
[null,"        Destination:=DestinationFolder & \"\\\" & MyFile.Name, Overwritefiles:=False"]
[null,"    End If"]
[null,"Next MyFile"]
[]
[null,"End Sub"]

{"sheet":"Ostatní-Poznámky","index":7,"n_rows":1,"n_cols":1,"rows_kept":1,"cut":false,"hidden":false,"merged":[[0,0,0,3]]}
["FileSystemObject - poznámky"]