我有一个VBA宏,可将excel行保存到.svg。该代码似乎运行良好,只是在svg文档中的双引号出现处添加了额外的双引号。这是我正在使用的VBA宏:
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
wsTemp.Move
Set wbNew = ActiveWorkbook
Set wsTemp = wbNew.Worksheets(1)
Dim myPath As String
myPath = "C:\Users\myname\Desktop\MJOMBA\Images\"
wbNew.SaveAs myPath & wsSource.Cells(r, 1).Value & ".svg", xlCSV
'wbNew.SaveAs "cell.Text" & r & ".svg", xlCSV 'new way
wbNew.Close
ThisWorkbook.Activate
r = r + 1
Loop
Application.DisplayAlerts = False
End Sub
下面是一个示例.svg代码(用于演示)
这段.svg代码
<?xml version="1.0" encoding="iso-8859-1"?>
成为
<?xml version=""1.0"" encoding=""iso-8859-1""?>
这不是预期的行为。我该如何避免这个问题?