Пример макроса: Чтение локального текстового файла с разделителями

Исходный пример на VBA
Sub ReadTextFileWithSeparators()  '' e28
    Dim StrLine As String
    Dim FSO As Object
    Dim TSO As Object
    Dim StrLineElements As Variant
    Dim Index As Long
    Dim i As Long
    Dim Delimiter As String
    
    Range("A1").Select
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set TSO = FSO.OpenTextFile(ThisWorkbook.Path & "\TestFile.txt")
    Delimiter = ","
    Index = 1
    
    Do While TSO.AtEndOfStream = False
        StrLine = TSO.ReadLine
        StrLineElements = Split(StrLine, Delimiter)
        
        For i = LBound(StrLineElements) To UBound(StrLineElements)
            Cells(Index, i + 1).value = StrLineElements(i)
        Next i
        
        Index = Index + 1
    Loop
    
    TSO.Close
    Set TSO = Nothing
    Set FSO = Nothing
End Sub 
JavaScript Р7
(function() {
    // ! Type correct path to file "TestFile.txt":
	function LoadFile() {
    $.ajax({
        type: "GET",
//        url: "file:///D:/work/Р7 Офис/Example 28/TestFile.txt",
//C:\docxl\JOB\In2SQL\Macros\Задание 241030
        url: "file:///C:/docxl/JOB/In2SQL/Macros/Задание 241030/TestFile.txt",
        dataType: "text",
        success: function(data) {processData(data);}
     });
    }
    
    function processData(allText) {
        var oWorksheet = Api.GetActiveSheet();
        
        // Array of text file lines (separated by '\r\n' chars)
        var allTextLines = allText.split(/\r\n|\n/);
        
        // Cell address
        var r = 1;  // row
        var c = 1;  // column

        // Iterate through all lines
        for (var line = 0; line < allTextLines.length; line++) {
            // Extract words separated by ',' char
            var words = allTextLines[line].split(',');
            
            for (var w = 0; w < words.length; w++) {
                oWorksheet.GetCells(r,c).SetValue(words[w]);
                c++;    // next column
            }
            r++;    // next row
            c = 1;  // first column
        }    
    }
    
    LoadFile();
    // Without this code file loading too slowly:
    let reload = setInterval(function(){
        Api.asc_calculate(Asc.c_oAscCalculateType.All);
    });    
})();
Поддержка слушателей курса
"Основы Java Script для Р7"