Blue Prism How to write a collection in MS Word VBO - blueprism

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

You can do the following:
1) Use a loop for your specified collection
2) Inside your loop use Object MS Word VBO and Action Type Text
3) In text field use the columns of your collection that you want to write to the word file (Example [Collection.Column1]&"-----"&[Collection.Column2])
4) Use Object MS Word VBO and Action Save As to save your file
5) Finally use Object MS Word VBO and Action Exit
Keep in mind that for the newest versions of Microsoft Suite you need to:
1) 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:
Hope these information will help you.

Related

How to use mailmerge macro from excel to word with a click of a button in the excel sheet

I am trying to create a code which will be executed with a click of a button in the excel sheet and will ask me for an input of a cell value in excel which will then take all the data from that cell's row and insert it accordingly in the word template where the mail merge tags are.
for example :
I have data like this in my excel sheet :
ID(A1), Name(B1), Last Name(C1), Country(D1), Date(E1)
378232625(A2), John(B2), Smith(C2), United States(D2), 29/02/2020(E2)
322783145(A3), Joshua(B3), Brand(C3), United States(D3), 27/02/2020(E3)
I want to have a button which will ask for an ID input and will then take all the other info of that person and place it in the word template in the correct place.
For example:
When a user runs the code it will pop up an input box and it will ask him to type an ID,
for example: 322783145
it will then check where the ID is placed(which row in A column) in the excel sheet which is A3 for this example and will pull the rest of this person's information into the word template I have created beforehand.(ID, Name, Last Name, Country and Date).
Later on I want to be able to automatically save it to pdf as well with the same button but first I want this to work.
Thanks in advance :D
You don't need VBA for this with the question as originally posted - simply use a SKIPIF field coded as:
{SKIPIF{MERGEFIELD ID}<> {FILLIN "Which ID do you want?" \o}}
or:
{SKIPIF«ID»<> {FILLIN "Which ID do you want?" \o}}
where 'ID' is the name of the data field in Excel you want to the merge to process.
With that, only the record containing that ID will be processed. No VBA required.
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Likewise, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required.
I see that you've added two new requirements, viz:
the mailmerge to be run from a button in Excel; and
for it "to be able to automatically save it to pdf as well".
You really shouldn't move the goal posts this way. Nor should you ask ask multiple distinct questions in the same thread. For code to run a merge from Excel (and send the output to PDF), see Run a Mailmerge from Excel, Sending the Output to Individual Files in the Mailmerge Tips & Tricks thread at: https://www.msofficeforums.com/mail-merge/21803-mailmerge-tips-tricks.html. Of course, once you get into using a macro such as this, you will need to add the logic for the ID selection to that code. Ask in a separate thread if you can't figure that out.

Blueprism Replace Characters in a collection

I have a collection with multiple columns. I want to search for any characters that have a fada/accent (eg. á) and replace them with the normal version of the character. So á would become a. This would be similar to ctrl f replace in excel.
Calculation stages have a "Replace" function available from the list under Functions>Text. To my knowledge, there is no standard feature available to do this once text is inside the collection. However, with this "Replace" function you should be able to have the fada/accents removed before the text goes into the Collection stage.
Ultimately I created an excel macro. The bot runs this macro and then reads the file into a collection

populate word template (with repeat) from excel

I have data in an Excel spreadsheet that I want to include in a report in Word.
In Excel, one line = one data entry.
In Word, each line will result in a layout block.
There are many lines, I want to define the template once and have whatever function imports from Excel duplicate it as often as necessary.
Mailmerge, AFAIK, creates seperate documents. That is not what I need, I need multiple blocks within one document.
Couldn't find a solution so far, everything points me to Mailmerge.
As requested, an example:
In Excel:
TEST - RESULT - REASON - COMMENT
Check A - failed - missing a foo - install a foo next time
Check B - success - ok - worked as designed
Check C - success - mostly ok - worked, but can be improved
In Word:
Test Report
Check Number: Check A
Check Result: failed (missing a foo)
Comment: install a foo next time
You get the idea. The actual template is not so simple, but the main idea is that fields are not identical to lines - there can be multiple fields in the same line, in different places around the template, etc.
I'm afraid you're not finished with Mail Merge yet!
multiple blocks within one document :
It's the same idea as labels... you're just not printing them onto labels, and you're making up a custo size and layout.
Office.com : Create and print labels using mail merge
More information, Google "word labels from excel data"...

Automatic Replace Rule for Word?

I have a Word document which I use for Mailings and it is linked to an Excel file.
Lets say that this Excel file contains a Code (FA139, FA140, etc.) and I would like that the Word Document replaces the code with a string of text every time within the mailing feature. This means, that when I click next, it shall get the code from the Excel File and replace it with the text.
It is not purpose of the question to modify the excel file, but do all necessary changes (if possible) in the Word file.
All you need is a series of fields in Word coded along the lines of:
{IF{MERGEFIELD Code}= "FA139" "Green"}{IF{MERGEFIELD Code}= "FA140" "Blue"}
or:
{IF«Code»= "FA139" "Green"}{IF«Code»= "FA140" "Blue"}
where 'Code' is the field name.
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Likewise, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required.

Looping through the ADO fields collection in VBA with an empty recordset

I have an ADO recordset that returns no rows (which is expected), but my watches panel shows a valid field collection, with column names that I want to store / capture.
However, using code like
x = rs.Fields(idx)
returns the error '3021' : Either BOF or EOF is True. Requested operation requires a current record.
My question is is it possible to read the Fields collection (noting that the contents that I can see in the watches panel appear correct and what I want to be able to grab), and if not, what are the "gotchas" that explain why?
Many thanks
Mike
You need name:
x = rs.Fields(idx).Name
Field(idx) is the value, which does not exists.

Resources