以下代码在列中包含前导零时会删除它们。我认为 PasteSpecial 会解决这个问题。有没有办法确保在此子填充 CSV 时保留任何前导零?
Sub PasteStufff()
Dim myRange As Range
Dim outFile As String
outFile = "mypath\path\file.csv"
Set myRange = Sheets("base").Range("A1:G1")
Set myRange = Range(myRange , myRange .End(xlDown))
Sheets("base").Select
myRange.Select
Selection.Copy
Workbooks.Add
ActiveSheet.Cells(1, 1).PasteSpecial xlPasteValues
ActiveWorkbook.SaveAs Filename:= _
outFile _
, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub