VBA 스크립트를 사용하여 다음과 같은 파일을 저장하고 있습니다."월-일-시-분"라는 폴더 안에"월-년"
어쨌든 Excel은 내 코드를 좋아하지 않습니다.
ActiveWorkbook.SaveAs "C:\Users\" & Environ$("UserName") & _
"\Documents\Workout Logs\" & _
Format$(Date, "mmmm-yyyy") & _
"\" & _
Format$(Date, "mmmm-dd") & Format$(Time, "hh-mm") & ".xls"
특히 이 부분은
"\" & _
경로 지정의 중단을 원하는 방식으로 어떻게 표현합니까?
Format$(Date, "mmmm-yyyy") & _
파일이 저장될 폴더로
Format$(Date, "mmmm-dd") & Format$(Time, "hh-mm") & ".xls"
에 넣어야 하나?
답변1
내 컴퓨터에서는 제대로 실행됩니다(Windows Excel 2013).
Sub test()
a = "C:\Users\" & Environ$("UserName") & _
"\Documents\Workout Logs\" & _
Format$(Date, "mmmm-yyyy") & _
"\" & _
Format$(Date, "mmmm-dd") & Format$(Time, "hh-mm") & ".xls"
MsgBox (a)
End Sub
메시지박스 결과C:\Users\username\Documents\Workout Logs\May-2016\May-1910-13.xls
문서를 저장하는 대신 문자열을 변수에 저장하는 것과 똑같습니다.