📜  excel vba 将工作表导出为 csv 而不会失去当前工作簿的焦点 - VBA 代码示例

📅  最后修改于: 2022-03-11 14:51:55.162000             🧑  作者: Mango

代码示例1
'VBA function to save current worksheet as a CSV file without losing
'focus. The CSV file is saved in the same directory as the current
'workbook. The Local Separator is utilized:

Sub SaveSheetAsCSV()
  With ActiveSheet
    .Copy
     ActiveWorkbook.SaveAs Left(.Parent.Name, InStrRev(.Parent.Name, ".")) & .Name & ".csv", xlCSV, Local:=True
     ActiveWorkbook.Close False
    .Activate
  End With
End Sub