Hi
I hope someone can help
I have a sheet that I export using VBA to convert it to csv using , as a delimeter. When I import this csv file using my 3rd party application, despite this csv file having plenty of commas within the file, the program still knows which columns to use and doesn't jumble the data around. I have been doing this successfully for ages. But now I would like to use a sheet created from power query and have that exported, but now when I export this as csv and then import to my 3rd party application it is jumbling all the data around where the commas are within the body. So I am assuming this csv does not export in the same format as the original. Here is the code I use to export the sheets. Any ideas would be much appreciated
Here is the code I use to export the sheets
Private Sub Export_LW_PQ_CSV_Btn_Click()
' Disable screen updating to improve performance
Application.ScreenUpdating = False
Application.DisplayAlerts = False ' Prevent overwrite alerts
' Refresh all data in the active workbook
ActiveWorkbook.RefreshAll
' Ask the user if they want to proceed with the export
Dim proceed As VbMsgBoxResult
proceed = MsgBox("Proceed With Exporting Inventory File To Linnworks Location?", vbQuestion + vbYesNo)
If proceed = vbYes Then
' Define the worksheet to export as CSV
Dim shtToExport As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("Master Products")
' Create a new workbook to copy the sheet
Dim wbkExport As Workbook
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
' Save the copied sheet as a CSV file
wbkExport.SaveAs Filename:="C:\Users\xxxja\Dropbox\Linnworks Importing\Linnworks_Product_Export.csv", FileFormat:=xlCSV
' Ask the user if they want to open the file location
Dim openLocation As VbMsgBoxResult
openLocation = MsgBox("Do you want to open the file location?", vbQuestion + vbYesNo)
If openLocation = vbYes Then
' Open Windows file location
Dim folderPath As String
folderPath = "C:\Users\xxxja\Dropbox\Linnworks Importing\"
Shell "explorer.exe """ & folderPath & """", vbNormalFocus
End If
' Close the exported workbook without saving changes
wbkExport.Close SaveChanges:=False
' Notify the user about successful export
MsgBox "Linnworks CSV Export Successful", vbInformation, "Exporting"
End If
' Enable screen updating and re-enable alerts
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I hope someone can help
I have a sheet that I export using VBA to convert it to csv using , as a delimeter. When I import this csv file using my 3rd party application, despite this csv file having plenty of commas within the file, the program still knows which columns to use and doesn't jumble the data around. I have been doing this successfully for ages. But now I would like to use a sheet created from power query and have that exported, but now when I export this as csv and then import to my 3rd party application it is jumbling all the data around where the commas are within the body. So I am assuming this csv does not export in the same format as the original. Here is the code I use to export the sheets. Any ideas would be much appreciated
Here is the code I use to export the sheets
Private Sub Export_LW_PQ_CSV_Btn_Click()
' Disable screen updating to improve performance
Application.ScreenUpdating = False
Application.DisplayAlerts = False ' Prevent overwrite alerts
' Refresh all data in the active workbook
ActiveWorkbook.RefreshAll
' Ask the user if they want to proceed with the export
Dim proceed As VbMsgBoxResult
proceed = MsgBox("Proceed With Exporting Inventory File To Linnworks Location?", vbQuestion + vbYesNo)
If proceed = vbYes Then
' Define the worksheet to export as CSV
Dim shtToExport As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("Master Products")
' Create a new workbook to copy the sheet
Dim wbkExport As Workbook
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
' Save the copied sheet as a CSV file
wbkExport.SaveAs Filename:="C:\Users\xxxja\Dropbox\Linnworks Importing\Linnworks_Product_Export.csv", FileFormat:=xlCSV
' Ask the user if they want to open the file location
Dim openLocation As VbMsgBoxResult
openLocation = MsgBox("Do you want to open the file location?", vbQuestion + vbYesNo)
If openLocation = vbYes Then
' Open Windows file location
Dim folderPath As String
folderPath = "C:\Users\xxxja\Dropbox\Linnworks Importing\"
Shell "explorer.exe """ & folderPath & """", vbNormalFocus
End If
' Close the exported workbook without saving changes
wbkExport.Close SaveChanges:=False
' Notify the user about successful export
MsgBox "Linnworks CSV Export Successful", vbInformation, "Exporting"
End If
' Enable screen updating and re-enable alerts
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub