Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim configFileList As Variant 'Premenna pre cely modul
- Sub RefreshMultipleFiles()
- Call GetFileList
- Dim i As Integer
- i = 0
- Dim fileOZ As Workbook
- Dim folderOZ As String
- 'Do While configFileList(i) <> "" - toto nefungovalo dobre, lebo neexistujúcu položku v arrayi nepovažuje za empty string ani za null
- Do While i < (UBound(configFileList) + 1) 'https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/ubound-function
- folderOZ = (Application.ThisWorkbook.Path & "/Users/")
- Set fileOZ = Workbooks.Open(folderOZ & configFileList(i)) 'https://www.mrexcel.com/board/threads/vba-code-loop-through-named-list-or-all-xls-files-in-a-directory.845397/
- Debug.Print ("OZ Filename[" & Format(Now, "hh:nn:ss") & "]: " & fileOZ.Name) 'Otvor si Immediate window (Ctrl+G) a uvidíš Debug.Print správy
- 'I can do here whatever I want
- fileOZ.Close
- Debug.Print Format(Now, "hh:nn:ss") & " -> Success"
- i = i + 1
- Loop
- End Sub
- Sub GetFileList()
- Dim configFilePath As String
- Dim configWhole As String
- Dim configArray As Variant 'nebude to fungovat so String ťhttps://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/data-type-summary
- configFilePath = Application.ActiveWorkbook.Path & "\FileNameList.txt" 'Application.ActiveWorkbook.Path vráti cestu do zložky aktívneho workbooku
- 'alternativa Application.ThisWorkbook.Path vráti cestu ku zložke v ktorej je súbor s týmto makrom
- Open configFilePath For Input As #1 'netusim ako funguje Open+Input+Close :(, viac info na https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/line-inputstatement
- configWhole = Input$(LOF(1), 1) 'tiez neviem ako to funguje :(
- Close #1
- configFileList = Split(configWhole, vbNewLine) 'https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/split-function
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement