I have got an additional requirement to save hard-coded data from excel sheet (Input.xlsx) (attached) to a excel sheet (in sheet 2 of output-23-10.xlsx) being generated out of below vbscript (Toxls.vbs) .
Looking to add new functionality in an existing utility vbscript (Toxls.vbs) to achieve copying hard-coded data from excel (Input.xlsx) to a excel sheet (sheet2 of output-23-10.xlsx ) being generated from below vbscript vbscript (Toxls.vbs) .
Toxls.vbs :- Used to convert Pipe Delimited text into an excel sheet (Output.xlsx).
' Create file system object
Set objFSO = CreateObject("Scripting.FilesystemObject")
' Files to work woth
strInputFile = objFSO.GetAbsolutePathname("C:\Users\user\Desktop\Input.txt")
strOutputFile = objFSO.GetAbsolutePathname("C:\Users\user\Desktop\output-23-10.xlsx")
' Read text file into array
With objFSO.OpenTextFile(strInputFile, 1)
arrInput = Split(.ReadAll, vbNewLine)
End With
' Start Excel, create a new worksheet
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.Workbooks.Add
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
' Initialize row index
intRow = 0
' Process each line of input file
For Each strInput in arrInput
' Skip all blank lines
If strInput <> "" Then
' Start a new row in Excel, start at first column
intRow = intRow + 1
intCol = 0
' Parse input text line
arrTokens = Split(strInput, "|")
' Add each value to Excel sheet
For Each strToken In arrTokens
intCol = intCol + 1
With objSheet.Cells(intRow, intCol)
.Value = Trim(strToken)
' Bold first row
If intRow = 1 Then
.Font.Bold = True
End If
' Borders on all cells
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
End With
Next
End If
Next
' Write file and close Excel
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs strOutputFile, cExcel7
objExcel.ActiveWorkbook.Close False
objExcel.Quit
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
-Mike Kapnisakis, Warner Bros
With your subscription - you'll gain access to our exclusive IT community of thousands of IT pros. You'll also be able to connect with highly specified Experts to get personalized solutions to your troubleshooting & research questions. It’s like crowd-sourced consulting.
We can't always guarantee that the perfect solution to your specific problem will be waiting for you. If you ask your own question - our Certified Experts will team up with you to help you get the answers you need.
Our certified Experts are CTOs, CISOs, and Technical Architects who answer questions, write articles, and produce videos on Experts Exchange. 99% of them have full time tech jobs - they volunteer their time to help other people in the technology industry learn and succeed.
We can't guarantee quick solutions - Experts Exchange isn't a help desk. We're a community of IT professionals committed to sharing knowledge. Our experts volunteer their time to help other people in the technology industry learn and succeed.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
This award recognizes a member of Experts Exchange who has made outstanding contributions to the community within their first year as an expert. The Rookie of the Year is awarded to a new expert who has the highest number of quality contributions.