(Solved) – How to save excel row data “as is” to .svg using a VBA macro


I have a working VBA Macro but for the life of me I can’t get it to completely work as expected. The macro saves row data to individual .svg files. Up to this point everything is fine. The problem is that I encountered an issue where the macro added double quotes to the .svg files thus ruining them. This was as a result of xlCSV but I changed this to xlTextPrinter. This worked but once again I encountered an issue where the svg code breaks where it’s not supposed to. For example

which ruins the code when you preview it.

I am completely stuck at this point. I want the macro to print just what is in the rows and that's it without interfering.

The macro is this one:

Sub SaveRowsAsSVGs()

Dim wb As Excel.Workbook, wbNew As Excel.Workbook
Dim wsSource As Excel.Worksheet, wsTemp As Excel.Worksheet
Dim r As Long, c As Long
Set wsSource = ThisWorkbook.Worksheets("Images")

Application.DisplayAlerts = False 'will overwrite existing files without asking
Application.ScreenUpdating = False

r = 1
Do Until Len(Trim(wsSource.Cells(r, 1).Value)) = 0
ThisWorkbook.Worksheets.Add ThisWorkbook.Worksheets(1)
Set wsTemp = ThisWorkbook.Worksheets(1)

For c = 2 To 7
wsTemp.Cells((c - 1) * 2 - 1, 1).Value = wsSource.Cells(r, c).Value
Next c

Set wbNew = ActiveWorkbook
Set wsTemp = wbNew.Worksheets(1)
Dim myPath As String
myPath = "C:UsersmynameDesktopMJOMBAImages"
wbNew.SaveAs myPath & wsSource.Cells(r, 1).Value & ".svg", xlCSV
'wbNew.SaveAs "cell.Text" & r & ".svg", xlCSV 'new way
r = r   1

Application.DisplayAlerts = False
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *