Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in RPA by (5.3k points)

I've got one problem. I need to write my collection which contains 50 rows into my MS Word file. How can I do it? I've checked that there is an action named Type Text, but it is only for text type, not for a collection. Could you please give me some advice ? Best regards

2 Answers

0 votes
by (9.5k points)

You should try doing this : 

Use a loop for your specified collection

Inside your loop use Object MS Word VBO and Action Type Text.

In text field use the columns of your collection that you want to write to the word file (Example [Collection.Column1]&"-----"&[Collection.Column2])

Use Object MS Word VBO and Action Save As to save your file

Finally use Object MS Word VBO and Action Exit

Use Object MS Word VBO and Action Show for your files when you want to write some values (in your case Word)

Check the solution below:

enter image description here

0 votes
by (140 points)
Dim doc as Object = GetDocument(handle,documentname)
Dim range As Object
'range = doc.Content.InsertAfter(text)
Try
Dim strbuilder As New StringBuilder
'Start with new line in word document.
strbuilder.AppendLine()
For J As Integer = 0 TO SourceCollection.Columns.Count-1
strbuilder.Append(SourceCollection.Columns(J).ColumnName & Chr(9))
Next
strbuilder.AppendLine()
For I As Integer = 0 To SourceCollection.Rows.Count-1
    Dim Values(SourceCollection.Columns.Count-1) As Object
    For J As Integer = 0 To SourceCollection.Columns.Count-1
        Values(J)=SourceCollection.Rows(I)(J)
        strbuilder.Append(Values(J)& Chr(9))
    Next
        strbuilder.AppendLine()
Next
range = doc.Content.InsertAfter(strbuilder.ToString)
Catch Ex As Exception
ExceptionMessage=Ex.ToString
End TryDim doc as Object = GetDocument(handle,documentname)
Dim range As Object
'range = doc.Content.InsertAfter(text)
Try
Dim strbuilder As New StringBuilder
'Start with new line in word document.
strbuilder.AppendLine()
For J As Integer = 0 TO SourceCollection.Columns.Count-1
strbuilder.Append(SourceCollection.Columns(J).ColumnName & Chr(9))
Next
strbuilder.AppendLine()
For I As Integer = 0 To SourceCollection.Rows.Count-1
    Dim Values(SourceCollection.Columns.Count-1) As Object
    For J As Integer = 0 To SourceCollection.Columns.Count-1
        Values(J)=SourceCollection.Rows(I)(J)
        strbuilder.Append(Values(J)& Chr(9))
    Next
        strbuilder.AppendLine()
Next
range = doc.Content.InsertAfter(strbuilder.ToString)
Catch Ex As Exception
ExceptionMessage=Ex.ToString
End Try
For more information or tech support visit Data Recovery Dubai

Related questions

0 votes
1 answer
asked Jul 22, 2019 in RPA by noah kapoor (5.3k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...