我想编写一个VBA makro来将选定的Excel工作表保存为csv文件。我收集到了什么:
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
SaveToDirectory = "G:\...\Create csv\" & Format(Date, "YYYYMMDD") & "_csv Save" & "\"
If Len(Dir(SaveToDirectory, vbDirectory)) = 0 Then
MkDir SaveToDirectory
End If
For Each WS In ThisWorkbook.Worksheets
If WS.Name = "Government_debt" Or WS.Name = "Domestic_demand" Or (...) Then
WS.SaveAs SaveToDirectory & WS.Name, xlCSV
End If
Next
我需要完成什么?
"YYYYMMDDHHMM"
解决方案为我提供了201504280000
CurDir()
和Application.ActiveWorkbook.Path
,但没有成功提前致谢!