Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


При условии, что файлы не гигабайтного размера:
читать дальше »
Код: Выделить весь код
Option Explicit

Const xlDelimited = 1

Dim objFSO
Dim strFile
Dim objTS
Dim strLine
Dim strContent
Dim arrContent
Dim i


If WScript.Arguments.Count > 0 Then
	Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
	
	With WScript.CreateObject("Excel.Application")
		With .Workbooks.Add
			For Each strFile In WScript.Arguments
				If objFSO.FileExists(strFile) Then
					With objFSO.OpenTextFile(strFile)
						strLine    = Trim(.ReadLine())
						strContent = .ReadAll()
						.Close
					End With
					
					If InStr(1, strContent, "INCORRECT SHUTDOWN !!!", vbTextCompare) > 0 Then
						arrContent = Split(strContent, vbCrLf)
						
						With .Worksheets.Add()
							.Name = strLine
							
							For i = LBound(arrContent) To UBound(arrContent)
								.Cells(i + 1, 1).Value = Trim(arrContent(i))
							Next
							
							With .UsedRange
								.TextToColumns , xlDelimited, , , , True
								.EntireColumn.AutoFit
							End With
						End With
					End If
				Else
					WScript.Echo "Can't find source file [" & strFile & "]."
				End If
			Next
		End With
		
		.Visible = True
	End With
	
	Set objFSO = Nothing
Else
	WScript.Echo "Usage: cscript.exe //nologo " & WScript.ScriptName & " <Source file1> <Source file2> ... <Source fileN>"
End If

WScript.Quit 0
Это сообщение посчитали полезным следующие участники:

Отправлено: 21:22, 28-10-2013 | #6