Hi Team,
I have extracted the json data and store in Datatable .
now I want to write data table in word file , so I am using vb script action for the same .
so let me know How I pass the data table variable in vs script
see the script
' Create an instance of the Word application
Set objWord = CreateObject("Word.Application")
' Make Word visible
objWord.Visible = True
' Add a new document
Set objDoc = objWord.Documents.Add()
' Define your DataTable variable (replace this with your actual DataTable variable)
Dim dataTable
' Get the DataTable variable passed as a command-line argument
Set dataTable = WScript.Arguments.Item(0)
' Assuming dataTable is your DataTable variable
' Get the number of rows and columns in the DataTable
numRows = dataTable.Rows.Count
numCols = dataTable.Columns.Count
' Add a table to the Word document
Set objTable = objDoc.Tables.Add(objDoc.Range, numRows + 1, numCols)
' Add column headers to the table
For col = 0 To numCols - 1
objTable.Cell(1, col + 1).Range.Text = dataTable.Columns(col).ColumnName
Next
' Add data to the table
For row = 0 To numRows - 1
For col = 0 To numCols - 1
objTable.Cell(row + 2, col + 1).Range.Text = dataTable.Rows(row)(col)
Next
Next
' Save the Word document
objDoc.SaveAs "C:\Users\sanket.shinde\Documents\@JsonExtraction\@JsonData\document.docx"
' Close the Word document and quit Word
objDoc.Close
objWord.Quit
' Release the objects
Set objTable = Nothing
Set objDoc = Nothing
Set objWord = Nothing
If you have any alternative solution for the same please let me know.
Thanks in advance!!!