내보내기에서 추가 텍스트 줄을 정의 할 방법이 없습니다.
당신은 고정 너비 형식으로 쿼리를 내보내려면 TransferSpreadsheet 메서드를 사용한다고 가정합니다. 이는 일반적으로 필드 헤더의 유무에 관계없이 고정 폭 컨텐츠를 생성하는 올바른 방법입니다.
데이터 내용 앞뒤에 파일에 줄을 추가하려면 기존 파일을 열고 새 파일을 만들고 헤더 줄을 추가 한 다음 기존 파일의 데이터를 추가해야합니다 새 파일에 추가 한 다음 바닥 글을 추가 한 다음 두 파일을 닫습니다.
파일 작업에 기본 제공되는 VBA 함수를 사용할 수는 있지만 Scripting.Runtime 라이브러리는 파일 작업에보다 직관적이고 객체 지향적 인 방법을 제공합니다.
당신은 .. 도구의 Microsoft 스크립팅 런타임 라이브러리에 대한 참조를 참조를 추가해야합니다
..
Sub EnhanceExportedFile()
Const exportedFilePath As String = "C:\Foo.txt"
Const newFilePath As String = "C:\NewFoo.txt"
Dim fso As Scripting.FileSystemObject
Dim exportedFile As TextStream
Dim newFile As TextStream
Dim rowCount As Long
Set fso = New Scripting.FileSystemObject
Set exportedFile = fso.OpenTextFile(exportedFilePath, ForReading, False)
Set newFile = fso.CreateTextFile(newFilePath, True)
'Append the date in ISO format
newFile.WriteLine Format(Now, "yyyy-mm-dd")
'Append each line in the exported file
Do While Not exportedFile.AtEndOfStream
newFile.WriteLine exportedFile.ReadLine
rowCount = rowCount + 1
Loop
'Append the total exported lines
newFile.WriteLine rowCount
'Close both files
exportedFile.Close
newFile.Close
End Sub
현재 날짜 "필드"다음에 더미 필드가있는 한 줄 헤더 쿼리를 만들고 전체 항목과 더미 빈 "필드"가있는 예고 쿼리를 만듭니다. 그런 다음 내보내기 전에 하나의 통합 쿼리로 모든 항목을 결합하십시오. – dbmitch