逗号到点导出文件

时间:2015-08-17 14:16:23

标签: xml excel export point comma

嗨,大家好,我在这里喝了一点腌菜。

我使用脚本,我使用互联网并略微调整,将excel中的一个工作表(sheet3)转换为单独的XML文件。该脚本完美无缺,但有一个问题。我在Excel中使用的值用逗号分隔 - > 184,6mm。由于导出到步骤,因此需要在excel中保持这样。然而,我导出的XML文件需要与点分开值 - > 184.6毫米。

这意味着在我的脚本中的某个地方我需要一个字符串,但是因为我是一名工程师而不是IT专家,所以我不能想出这个...希望你们没有什么可以帮助我。

这是我目前的剧本:

Sub Export_Files()
Dim sExportFolder, sFN
Dim rArticleName As Range
Dim rDisclaimer As Range
Dim oSh As Worksheet
Dim oFS As Object
Dim oTxt As Object


'sExportFolder = path to the folder you want to export to
'oSh = The sheet where your data is stored
sExportFolder = Application.ActiveWorkbook.Path
Set oSh = Worksheets("Sheet3")

Set oFS = CreateObject("Scripting.Filesystemobject")

For Each rArticleName In oSh.UsedRange.Columns("A").Cells
    Set rDisclaimer = rArticleName.Offset(, 1)

    'Add .txt to the article name as a file name
    sFN = rArticleName.Value & ".XML"
    Set oTxt = oFS.OpenTextFile(sExportFolder & "\" & sFN, 2, True)
    oTxt.Write rDisclaimer.Value
    oTxt.Close
Next
End Sub

更新!此外,我尝试了以下代码并产生负面影响:

Sub Export_Files()
Dim sExportFolder, sFN
Dim rArticleName As Range
Dim rDisclaimer As Range
Dim oSh As Worksheet
Dim oFS As Object
Dim oTxt As Object

Worksheets("Sheet3").Activate
ActiveSheet.UsedRange.Replace What:=",", Replacement:="."
'sExportFolder = path to the folder you want to export to
'oSh = The sheet where your data is stored
sExportFolder = Application.ActiveWorkbook.Path
Set oSh = Worksheets("Sheet3")

Set oFS = CreateObject("Scripting.Filesystemobject")

For Each rArticleName In oSh.UsedRange.Columns("A").Cells
Set rDisclaimer = rArticleName.Offset(, 1)

'Add .txt to the article name as a file name
sFN = rArticleName.Value & ".XML"
Set oTxt = oFS.OpenTextFile(sExportFolder & "\" & sFN, 2, True)
oTxt.Write rDisclaimer.Value
oTxt.Close
Next
End Sub

Sub Export_Files()
Dim sExportFolder, sFN
Dim rArticleName As Range
Dim rDisclaimer As Range
Dim oSh As Worksheet
Dim oFS As Object
Dim oTxt As Object


'sExportFolder = path to the folder you want to export to
'oSh = The sheet where your data is stored
sExportFolder = Application.ActiveWorkbook.Path
Set oSh = Worksheets("Sheet3")

Set oFS = CreateObject("Scripting.Filesystemobject")
oSh.Columns(1).Replace ",", ".", xlPart    
For Each rArticleName In oSh.UsedRange.Columns("A").Cells
    Set rDisclaimer = rArticleName.Offset(, 1)

    'Add .txt to the article name as a file name
    sFN = rArticleName.Value & ".XML"
    Set oTxt = oFS.OpenTextFile(sExportFolder & "\" & sFN, 2, True)
    oTxt.Write rDisclaimer.Value
    oTxt.Close
Next

End Sub

0 个答案:

没有答案