Как изменить программу. Нам нужно изменить нашу программу. Нам нужно прочитать все файлы

Автор sergey, 15 октября 2024, 16:47

sergey

Как изменить программу. Нам нужно изменить нашу программу.

Нам нужно прочитать все файлы .htm как обычный текст в папке c:\Untitled и по числам 338-232, 34k-33k, dj-34 берут значение после "school-" Wkd и вставляют значение столбца school в файл excel.

index.php-route=information-news&page=76.htm

number 338-232
school- Wkd

index.php-route=information-news&page=5.htm

number 34k-33k
school- kla

file 3.htm

number dj-34
school- ece
Visual BasicВыделить код
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Option Explicit
Sub Test1()

  Dim FileSysObj As Object
  Dim FolderObj As Object
  Dim FileColl As Object
  Dim FileObj As Object

  Dim PathSearch As String

  ' This assumes the text files are in the same folder as the workbook holding the macro.
  ' Use PathSearch = "C:\ ..." if you would rather have the files in a different folder.
  PathSearch = ActiveWorkbook.Path

  Set FileSysObj = CreateObject("Scripting.FileSystemObject")
  Set FolderObj = FileSysObj.getfolder(PathSearch)
  Set FileColl = FolderObj.Files

  For Each FileObj In FileColl
    With FileObj
      If LCase(Right(.Name, 4)) = ".txt" Then
        Debug.Print .Name & "  " & .DateCreated & "  " & .Size & " bytes"
      End If
    End With
  Next

End Sub

Администратор