Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Main()
- Dim Xdoc
- Public sub Main()
- Dim args
- Dim argsCount
- Set args = Wscript.Arguments
- argsCount = Wscript.Arguments.Count
- if (argsCount = 2) then
- if (args(0) = "-h") then
- Wscript.echo "You should input xml file name and doc file name"
- else
- Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
- Set file = objFSO.GetFile(args(0))
- if not right(file.name,4) =".xml" then
- set StdErr = Wscript.StdErr
- StdErr.write "Error: Not a xml file "
- WScript.Echo args(0)
- else
- Dim obj
- Dim Check
- Check = CreateDoc(obj)
- Set XDoc = CreateObject("Msxml2.DOMDocument.6.0")
- if (XDoc.Load(args(0))) then
- Dim N
- N = 0
- for each node in XDoc.SelectNodes("//Section")
- N = N + 1
- Next
- Dim table
- Check = Init_Table(N,4,table,obj)
- Check = FillTable(table, obj)
- obj.SaveAs(args(1))
- obj.Application.Quit
- else
- set StdErr = Wscript.StdErr
- StdErr.write "Error: Couldn't read xml file "
- WScript.Echo args(0)
- end if
- end if
- end if
- else
- Wscript.echo "You should input xml file name and doc file name "
- end if
- end sub
- Private Function Init_Table(NumRows0, NumColumns0, Table, obj)
- Set myRange = obj.Range(0, 0)
- Set Table = obj.Tables.Add(myRange, NumRows0, NumColumns0)
- Table.AutoFitBehavior (wdAutoFitWindow)
- Table.Borders.Enable = True
- Init_Table = 0
- End Function
- Private Function CreateDoc(obj)
- Set obj = CreateObject("Word.Application")
- obj.Visible = False
- Set obj = obj.Documents.Add()
- CreateDoc = 1
- end Function
- Private Function FillTable(table, obj)
- Dim T1
- Dim T2
- Dim T3
- Dim T4
- For Each Node In XDoc.SelectNodes("//Sections/*")
- T4 = False
- If Node.nodeName = "Section" Then
- I = I + 1
- N = N + 1
- T1 = Node.Attributes.Item(0).text
- T2 = Node.Attributes.Item(1).text
- T3 = Node.Attributes.Item(2).text
- For Each SymbolNode In XDoc.SelectNodes("//Symbols/*")
- If SymbolNode.Attributes.Item(1).text = Node.Attributes.Item(1).text Then
- For Each ExportNode In XDoc.SelectNodes("//Exports/*")
- If ExportNode.Attributes.Item(1).text = SymbolNode.Attributes.Item(2).text Then
- T4 = True
- End If
- Next
- End If
- Next
- table.Cell(N, 1).Range.text = T1
- table.Cell(N, 2).Range.text = T2
- table.Cell(N, 3).Range.text = T3
- table.Cell(N, 4).Range.text = T4
- End If
- Next
- FillTable = 1
- end Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement