Advertisement
Johniny

Read from txt file

Mar 4th, 2020
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub ReadFromFile()
  2.  
  3. Dim configFile As String
  4. Dim configWhole As String
  5. Dim configArr As Variant 'nebude to fungovat so String https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/data-type-summary
  6.  
  7. configFile = Application.ActiveWorkbook.Path & "\config.txt" 'Application.ActiveWorkbook.Path vráti cestu do zložky aktívneho workbooku
  8.    'alternativa Application.ThisWorkbook.Path vráti cestu ku zložke v ktorej je súbor s týmto makrom
  9. Open configFile 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
  10. configWhole = Input$(LOF(1), 1)
  11. Close #1
  12. configArr = Split(configWhole, vbNewLine) 'https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/split-function
  13.  
  14. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement