Building Custom UFO Tasks: Automating Excel, Word, and Outlook with Natural Language
Practical examples of automating Microsoft Office applications with UFO — from Excel data manipulation and Word document formatting to Outlook email workflows, with multi-step task descriptions and result verification.
Writing Effective Task Descriptions
The quality of UFO's automation depends heavily on how you describe the task. Vague instructions lead to unpredictable behavior. Specific, step-oriented descriptions produce reliable results.
Here are principles for writing good UFO task descriptions:
- Be explicit about the target application — "In Excel" is better than "in the spreadsheet"
- Describe the end state, not just the action — "Set cell B5 to the sum of B2 through B4" is better than "do some math in B"
- Order matters for multi-step tasks — describe steps in the sequence they should execute
- Include verification criteria — "Verify the total in B10 equals 1,500" helps UFO confirm success
Excel Automation Examples
Example 1: Data Entry and Formatting
python -m ufo --task "In the open Excel workbook, go to Sheet1. Enter the following data starting at cell A1: headers are Name, Revenue, Quarter. Row 2 is Acme Corp, 150000, Q1. Row 3 is Beta Inc, 230000, Q1. Row 4 is Gamma LLC, 89000, Q1. Then select the header row and make it bold. Auto-fit all column widths."
This task exercises multiple action types: cell navigation, text entry, selection, formatting toolbar interaction, and menu access.
Example 2: Formula Creation and Charting
python -m ufo --task "In the open Excel spreadsheet, add a SUM formula in cell B5 that totals B2 through B4. Format B5 as currency with no decimal places. Then select the range A1 to B4 and insert a bar chart. Move the chart below the data table."
Example 3: Conditional Formatting
python -m ufo --task "In Excel, select the range B2 to B100. Apply conditional formatting so that cells with values greater than 100000 have a green background and cells with values less than 50000 have a red background."
Automating These Tasks Programmatically
You can also invoke UFO from Python scripts for batch automation:
See AI Voice Agents Handle Real Calls
Book a free demo or calculate how much you can save with AI voice automation.
import subprocess
import json
def run_ufo_task(task: str, timeout: int = 300) -> dict:
"""Run a UFO task and return the result."""
result = subprocess.run(
["python", "-m", "ufo", "--task", task],
capture_output=True,
text=True,
timeout=timeout,
cwd="C:\\path\\to\\UFO"
)
return {
"returncode": result.returncode,
"stdout": result.stdout,
"stderr": result.stderr,
"success": result.returncode == 0
}
# Excel automation
excel_tasks = [
"In Excel, open the file C:\\Reports\\Q1_Sales.xlsx",
"In Excel, select all data in Sheet1 and sort by column B in descending order",
"In Excel, create a pivot table from the data in Sheet1 summarizing Revenue by Quarter",
]
for task in excel_tasks:
print(f"Running: {task}")
result = run_ufo_task(task)
if not result["success"]:
print(f"Task failed: {result['stderr']}")
break
print(f"Completed in output: {result['stdout'][-200:]}")
Word Automation Examples
Example 1: Document Creation
python -m ufo --task "In Microsoft Word, create a new document. Set the title to Quarterly Business Review. Add three headings: Executive Summary, Financial Highlights, and Next Steps. Under Executive Summary, type a placeholder paragraph. Save the document as QBR_Q1_2026.docx on the Desktop."
Example 2: Formatting and Styles
python -m ufo --task "In the open Word document, select all text and change the font to Calibri 11pt. Change the title to Heading 1 style. Change all section headings to Heading 2 style. Add page numbers in the footer."
Outlook Automation Examples
python -m ufo --task "In Outlook, create a new email. Set the To field to finance@company.com. Set the Subject to Q1 Sales Report Ready. In the body type: Hi team, the Q1 sales report has been finalized and is available in the shared drive. Please review by end of week. Best regards. Then click Send."
Multi-Application Workflow: Excel to Outlook
The most powerful UFO use case is chaining actions across applications:
def excel_to_email_workflow():
"""Extract data from Excel and send it via Outlook."""
# Phase 1: Excel data extraction
run_ufo_task(
"In Excel, open C:\\Reports\\Q1_Sales.xlsx. "
"Go to the Summary sheet. Select cells A1 through D10. "
"Copy the selection to clipboard."
)
# Phase 2: Email composition
run_ufo_task(
"In Outlook, create a new email. "
"Set To to finance@company.com and CC to cfo@company.com. "
"Set Subject to Q1 Sales Summary. "
"In the body, type 'Please find the Q1 sales summary below:' "
"then press Enter twice and paste the clipboard contents. "
"Click Send."
)
print("Excel-to-Email workflow completed")
FAQ
Can UFO handle Office 365 web versions in the browser?
UFO is designed for native Windows desktop applications, not browser-based Office 365. For web-based Office, browser automation tools like Playwright or Selenium are more appropriate. However, you could use UFO to automate a browser window if the browser exposes proper UIA elements.
How reliable is UFO for production Office automation compared to COM/VBA?
COM automation via win32com or VBA macros is more reliable and faster for repetitive, well-defined Office tasks. UFO is better for tasks that are difficult to script programmatically — such as interacting with complex dialog boxes, formatting charts by visual appearance, or handling dynamic content layouts.
What happens if an Office application crashes during a UFO task?
If the application crashes, UFO's next screenshot capture will show a different state (perhaps a recovery dialog or a missing window). The HostAgent will detect that the expected application is no longer available and report a task failure. You should implement retry logic in your orchestration script.
#OfficeAutomation #ExcelAutomation #WordAutomation #OutlookAutomation #MicrosoftUFO #NaturalLanguageUI #AIWorkflow #DesktopRPA
CallSphere Team
Expert insights on AI voice agents and customer communication automation.
Try CallSphere AI Voice Agents
See how AI voice agents work for your industry. Live demo available -- no signup required.