How to write in a table created on word with openrpa

Hello, How do we write with openrpa in certain cells of a table created in word?, are there “toolboxes” made on purpose or is it better to manage it with “invoke code”?

There is currently only support for that toward Excel
You COULD create it in excel and then use copy’n’paste into word, but i generally don’t like anything that involves clipboard from RPA.
If you know how to do it, using code, you could still use openrpa to “manage” the documents and get them open, and then InvokeCode has PIA loaded so you can easily start working with Word from there in. ( if you use c#/vb … but i know there is also a few python modules that can work with office, but i don’t know if any of them support working with tables in word )
but is not something i can assist with

1 Like

hi @Bryan_Junior

I’m currently working on a process where I have to save some data in ms-word, and I’m using Python (always and forever lol) and “invoke code” activity to do it.
Basically I have a script to fill in a predefined Word template (.doc) based on json structure, this script will first receive the JSON structure as a Python dictionary. Then, it will use a Word document and fill it in with the JSON data. Finally, it will save the document as a new file called output.doc.
In this example, using python-docx:

import json
import docx

# Define the JSON structure
jsonData = {
    'name': 'John Doe',
    'email': 'john.doe@example.com',
    'phone': '123-456-7890'
}

# Define the template file
templateFile = 'my_template.docx'

# Define the full path
strPath = 'templates/' + templateFile

# Create a new Word document
try:
    document = docx.Document(strPath)
except FileNotFoundError:
    print('The template file could not be found.')
except Exception as e:
    print('An unexpected error occurred: {}'.format(e))

# Fill in the template with the JSON data
for key, value in jsonData.items():
    document.replace_all('{' + key + '}', value)

# Save the document
document.save('output.doc')

# Log the actions that were taken
print('Created a new Word document.')
print('Filled in the template with the JSON data.')
print('Saved the document.')

This one works with word manipulation: python-docx — python-docx 0.8.11 documentation

Hope this helps you!

1 Like

I can not wait till you start looking into agents. It is going to be crazy.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.