Excel save as with name being data in a cell "computer name"

I’m a newbie!!!

I am working on a inventory script “system_profiler” to run on all my computers to save an excel file to a network share.
The name of excel needs to be data field “Computer name”
Also helpful path “fs1/inventoryreport” would be a network share already mounted.


mount volume “afp://MCSD_inventory:*******@fs1/inventoryreport”
→ mounts volume to save file
set dt to path to desktop folder as text
do shell script “system_profiler -xml SPHardwareDataType > ~/Desktop/HardwareData.xml”
tell application “System Events”
set hardwareData to XML element 1 of XML element 6 of XML element 1 of XML element 1 of XML element 1 of contents of XML file (dt & “HardwareData.xml”)
set hardWareList to {}
set countHardwareData to count XML elements of hardwareData
repeat with i from 1 to countHardwareData by 2
set v to value of XML element i of hardwareData
if v is not “_name” then
set end of hardWareList to {v, value of XML element (i + 1) of hardwareData}
end if
end repeat
end tell
tell (system info)
set end of hardWareList to {“computer name”, computer name}
set end of hardWareList to {“IPv4 address”, IPv4 address}
set end of hardWareList to {“primary Ethernet address”, primary Ethernet address}
set end of hardWareList to {“system version”, system version}
end tell
do shell script "rm " & quoted form of (POSIX path of dt & “HardwareData.xml”)
tell application “Microsoft Excel”
set maxRow to (countHardwareData div 2 + 3)
set value of range (“A1:B” & maxRow) of active sheet to hardWareList
tell active workbook
make new worksheet at end
end tell
→ sheet “Sheet2” of active workbook of application “Microsoft Excel”
activate object worksheet “Sheet1”
set i to 1
set b to 1
repeat with i from 1 to 30
copy range row i
paste special cell 1 of column b of sheet 2 with transpose
set b to b + 1
tell application “System Events” to set the clipboard to “”
end repeat
end tell
→ Sheet1 special past to sheet2 data transposed.

tell application "Finder" to eject "inventoryreport"
--> ejects mounted volume

end tell