Skip to content

Instantly share code, notes, and snippets.

@SpacePurr
Last active June 4, 2020 12:02
Show Gist options
  • Save SpacePurr/9ad89671e8b8ed00a41d9b2a14238c1e to your computer and use it in GitHub Desktop.
Save SpacePurr/9ad89671e8b8ed00a41d9b2a14238c1e to your computer and use it in GitHub Desktop.
Set WshShell = CreateObject("WScript.Shell")
Set Objects = ThisApplication.Root.Objects(0)
Set xdoc = CreateObject("MSXML2.DOMDocument")
set rows = xdoc.appendChild(xdoc.CreateElement("rows"))
'creating columns
set row = rows.appendChild(xdoc.CreateElement("row"))
set cell = row.appendChild(xdoc.createElement("cell"))
cell.SetAttribute "value", ""
For Each attr In Objects.Objects(0).Attributes
set cell = row.appendChild(xdoc.createElement("cell"))
cell.SetAttribute "value", attr.Description
'set style
set style = cell.appendChild(xdoc.createElement("style"))
set font = style.appendChild(xdoc.createElement("font"))
font.SetAttribute "bold", "true"
Next
'creating rows
For Each Object In Objects.Objects
set row = rows.appendChild(xdoc.CreateElement("row"))
set cell = row.appendChild(xdoc.createElement("cell"))
cell.SetAttribute "value", Object.Description
'set style
set style = cell.appendChild(xdoc.createElement("style"))
set font = style.appendChild(xdoc.createElement("font"))
font.SetAttribute "bold", "true"
For Each attr In Object.Attributes
set cell = row.appendChild(xdoc.createElement("cell"))
cell.SetAttribute "value", attr.Value
Next
Next
set row = rows.appendChild(xdoc.CreateElement("row"))
set cell = row.appendChild(xdoc.createElement("cell"))
cell.SetAttribute "merge", 2
cell.SetAttribute "value", "Автор"
set style = cell.appendChild(xdoc.createElement("style"))
set font = style.appendChild(xdoc.createElement("font"))
font.SetAttribute "italic", "true"
font.SetAttribute "color", "200;200;200"
set cell = row.appendChild(xdoc.createElement("cell"))
cell.SetAttribute "value", "Константин"
set style = cell.appendChild(xdoc.createElement("style"))
set fill = style.appendChild(xdoc.createElement("fill"))
fill.SetAttribute "color", "200;200;200"
xml = ThisApplication.WorkFolder + "\wordData.xml"
xdoc.save xml
excel = ThisApplication.WorkFolder + "\excel.xlsx"
exe = "E:\C#\Projects\_TDMS\TDMSOfficeCreate\TDMSOfficeCreate\bin\Debug\TDMSOfficeCreate.exe"
exe = """" & exe & """" & " "
xml = """" + xml + """" + " "
excel = """" + excel + """"
WshShell.Run exe + xml + excel, 1, 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment