Vba
Write a file
Dim SFile As Object, FSO as Object
Set fso = CreateObject ("Scripting.FileSystemObject")
Sfile.writeline (String (8, "") & "<Request>")
Sfile.close
Set SFile = Nothing
Set FSO = Nothing
Select Folder
With Application.filedialog (msoFileDialogFolderPicker)
If. Show =-1 Then
folder =. SelectedItems (1)
End If
End with
MsgBox Folder & "/taskinfo.xml"
Cyclic/if
Do While Cells (RowIndex, 2). Value <> ""
For compcol = 8 to + Step 1
If Idstr < Ten Then
Sfile.writeline (String ("") & "<complete id=" "0" & idstr & ""/> ")
Else
Sfile.writeline (String ("") & "<complete id=" "" & Idstr & ""/> ")
End If
Next Compcol
Loop
Complete
Sub CreateFile ()
Dim SFile As Object, FSO as Object
Set fso = CreateObject ("Scripting.FileSystemObject")
folder = "D:"
With Application.filedialog (msoFileDialogFolderPicker)
If. Show =-1 Then
folder =. SelectedItems (1)
End If
End with
MsgBox Folder & "/taskinfo.xml"
Set sFile = fso. CreateTextFile (Folder & "/taskinfo.xml", True)
Sfile.writeline ("<?xml version=" "1.0" "encoding=" "UTF-8" "?>")
Sfile.writeline ("<Tasks>")
RowIndex = 4
Do While Cells (RowIndex, 2). Value <> ""
' タスクid
TaskId = Cells (RowIndex, 2). Value
' Home electricity's really into elephant
obj = Cells (RowIndex, 4). Value
Sfile.writeline (String (4, "") & "<task id=" "" & TaskId & "" obj= "" "& Obj &" ">"
Sfile.writeline (String (8, "") & "<Request>")
For compcol = 8 to + Step 1
' Supplemental ID
Compid = Cells (RowIndex, Compcol). Value
If compid <> "Then
Idstr = compCol-7
If Idstr < Ten Then
Sfile.writeline (String ("") & "<complete id=" "0" & idstr & ""/> ")
Else
Sfile.writeline (String ("") & "<complete id=" "" & Idstr & ""/> ")
End If
End If
Next Compcol
Sfile.writeline (String (8, "") & "</Request>")
' URL
URL = Cells (RowIndex, 5). Value
' Path
Path = Cells (RowIndex, 6). Value
' Method
method = Cells (RowIndex, 7). Value
Sfile.writeline (String (8, "") & "<api url=" "" & URL & "" Path= "" "& Path &" "Method=" "" & Method & "" > ")
Sfile.writeline (String ("") & "<Input>")
' into force definition
Inputtext = Cells (RowIndex, 18). Value
Sfile.writeline (Inputtext)
Sfile.writeline (String ("") & "</Input>")
Sfile.writeline (String (8, "") & "</Api>")
Sfile.writeline (String (8, "") & "<Response>")
' Output 対応 answer
Outputstatus = Cells (RowIndex, 19). Value
Sfile.writeline (Outputstatus)
Sfile.writeline (String (8, "") & "</Response>")
Sfile.writeline (String (4, "") & "</Task>")
Sfile.writeline
RowIndex = RowIndex + 1
Loop
Sfile.writeline ("</Tasks>")
Sfile.close
Set SFile = Nothing
Set FSO = Nothing
End Sub
Sub DeleteFile ()
Dim FSO as Object
Set fso = CreateObject ("Scripting.FileSystemObject")
Fso. DeleteFile ("D:/testfile.txt")
End Sub
VBA read Excel Write XML