エクスポートで余分なテキスト行を定義する方法はありません。
あなたは、固定幅形式でクエリをエクスポートするために、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
現在の日付「フィールド」の後にダミーフィールドを含む1行のヘッダークエリを作成し、合計アイテムと同じダミーブランクの「フィールド」を含むトレーラクエリを作成します。そして、エクスポートする前にそれらを1つの結合クエリで一緒に結合してください...うまくいくかもしれません – dbmitch