Estou usando esta postagem
Com base na resposta, ele salva meu arquivo .csv
exportado no meu C:\Users\username\AppData\Roaming\Microsoft\Excel\XLSTART
.
No entanto, eu preciso dessa exportação para o local do meu arquivo, de onde estou exportando dados. Deve ser C:\Users\username\Desktop\Sample_Files\Excel_to_csv_export
Eu tentei o seguinte com base na resposta:
Sub ExportTable()
Dim wb As Workbook, wbNew As Workbook
Dim ws As Worksheet, wsNew As Worksheet
Dim wbNewName As String
Set wb = ThisWorkbook
Set ws = ActiveSheet
Set wbNew = Workbooks.Add
'I set the path below, which did not work
Set Path = 'C:\Users\username\Desktop\Sample_Files\Excel_to_csv_export'
With wbNew
Set wsNew = wbNew.Sheets("Sheet1")
wbNewName = ws.ListObjects(1).Name
ws.ListObjects(1).Range.Copy
wsNew.Range("A1").PasteSpecial Paste:=xlPasteAll
.SaveAs Filename:=wb.Path & "\" & wbNewName & ".csv", _
FileFormat:=xlCSVMSDOS, CreateBackup:=False
End With
End Sub
Como posso definir o caminho para o caminho desejado? Qualquer ajuda seria ótima!
Tags csv export microsoft-excel vba