|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
大神们,我搞了一个修改xml的vba, 可替换修改,但搞出来的东西是乱码,而且有错执行不了
求助先选择文件后打开
修改的地方就是把tag<j_t6_ttl>改为<j_s2_ttl>,<s_t12_ttl>改为<s_s1_ttl>
最后保存
谢谢了
- Private Sub CommandButton1_Click()
-
- Dim FileName As Variant
- Dim Arr, k%
- Dim sFileName As String
- Dim sPathName As String
- Dim aFile As Variant
- Dim ws As Worksheet
- Dim fd As FileDialog
- Set ws = Worksheets("Sheet1")
- FileName = Application.GetOpenFilename("xml File (*.xml),*.xml")
-
- Open FileName For Input As #1
- Arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf)
- Reset
-
- 'Open ThisWorkbook.Path & "\1300_TENKEN_old.xml" For Output As #1
-
- For k = 0 To UBound(Arr)
- Arr(k) = Replace(Arr(k), "j_t6_ttll", "j_s2_ttl")
- Arr(k) = Replace(Arr(k), "s_t12_ttl", "s_s1_ttl")
- Arr(k) = Replace(Arr(k), "s_t6_ttl", "s_s2_ttl")
- Arr(k) = Replace(Arr(k), "s_s12_ttl", "s_s1_ttl")
- Arr(k) = Replace(Arr(k), "/order", "/s_order")
- Arr(k) = Replace(Arr(k), "t12_display", "s1_display")
- Arr(k) = Replace(Arr(k), "t12_fee", "s1_fee")
- Arr(k) = Replace(Arr(k), "t6_fee", "s2_fee")
- Arr(k) = Replace(Arr(k), "t12_total_fee", "s1_total_fee")
- Arr(k) = Replace(Arr(k), "t6_total_fee", "s2_total_fee")
- Arr(k) = Replace(Arr(k), "t6_total_display", "s_total_display")
- Arr(k) = Replace(Arr(k), "</s_s1_ttl4>", "</s_s1_ttl4>" & Chr(10) & "<s_s1_ttl5></s_s1_ttl5>" & Chr(10) & "<s_s1_total></s_s1_total>")
- Arr(k) = Replace(Arr(k), "</j_s1_ttl4>", "</j_s1_ttl4>" & Chr(10) & "<j_s1_ttl5></j_s1_ttl5>" & Chr(10) & "<j_s1_total></j_s1_total>")
- Arr(k) = Replace(Arr(k), "</s_s2_ttl4>", "</s_s2_ttl4>" & Chr(10) & "<s_s2_ttl5></s_s2_ttl5>" & Chr(10) & "<s_s2_total></s_s2_total>")
- Arr(k) = Replace(Arr(k), "</j_s2_ttl4>", "</j_s2_ttl4>" & Chr(10) & "<j_s2_ttl5></j_s2_ttl5>" & Chr(10) & "<j_s2_total></j_s2_total>")
- Arr(k) = Replace(Arr(k), "</s1_fee4>", "</s1_fee4>" & Chr(10) & "<s1_fee5></s1_fee5>")
- Arr(k) = Replace(Arr(k), "</s2_fee4>", "</s2_fee4>" & Chr(10) & "<s2_fee5></s2_fee5>")
- Arr(k) = Replace(Arr(k), "t12_total_display", "")
-
- Print #1, Arr(k)
- Next
- Reset
- MsgBox "Opertion done!"
- End Sub
复制代码
|
|