Export xml ตามจำนวนที่กำหนด
Posted: Tue Dec 17, 2013 6:35 pm
คือผมอยากจะเพิ่ม Code ให้ Export XML ออกมาไฟล์ล่ะ 100 แถว เช่น มีทั้งหมด 200 แถว Export ออกมาก็จะได้ 2 ไฟล์
รบกวนดูให้หน่อยครับ
รบกวนดูให้หน่อยครับ
Code: Select all
Sub Button1_Click()
Dim TheText
Dim TheLineText
TheText = "<?xml version=""1.0""?><product>"
For i = 3 To 10000
If Sheet1.Cells(i, 2) <> "" Then
TheLineText = "<p"
For j = 1 To 15
theCell = Sheet1.Cells(i, j)
theCell = Replace(theCell, "<", "<")
theCell = Replace(theCell, """", """)
theCell = Replace(theCell, ">", ">")
theCell = Replace(theCell, "&", "&")
TheLineText = TheLineText & " C" & j & "=""" & theCell & """"
Next
TheLineText = TheLineText & "></p>"
TheText = TheText & TheLineText
Else
Exit For
End If
Next
TheText = TheText & "</product>"
TheFilePath = Application.ActiveWorkbook.Path
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(TheFilePath & "\Product.xml", True)
a.WriteLine (TheText)
a.Close
End Sub