作成の目的
Excelファイルでなく、テキストファイルで進捗ファイルを提出するように依頼されたため、
マクロを作成した。
Sub ファイル出力を行う()
' 出力ファイルのフルパス
Dim OutputSaki As String
' ファイル番号
Dim FileNum As Integer
Dim i As Long
Dim TodayDate As String
TodayDate = Format(Date, "mmdd")
OutputSaki = ActiveWorkbook.Path & "\" & TodayDate & "_" & "進捗報告.txt"
FileNum = FreeFile
Dim FileAriHantei As Long
Dim BookPathAndName As String
BookPathAndName = ThisWorkbook.Path
If Dir(OutputSaki) <> "" Then
FileAriHantei = MsgBox("ファイルがすでに存在します" & vbCrLf & _
"上書きしますか?", vbYesNo)
If FileAriHantei = vbNo Then
Exit Sub
End If
End If
Open OutputSaki For Output As FileNum
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Print #FileNum, Cells(i, "A").Value & Cells(i, "B").Value
Next i
Close FileNum
End Sub