Skip to content
Learn Agentic AI
Learn Agentic AI12 min read4 views

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.

flowchart TD
    START["Building Custom UFO Tasks: Automating Excel, Word…"] --> A
    A["Writing Effective Task Descriptions"]
    A --> B
    B["Excel Automation Examples"]
    B --> C
    C["Automating These Tasks Programmatically"]
    C --> D
    D["Word Automation Examples"]
    D --> E
    E["Outlook Automation Examples"]
    E --> F
    F["Multi-Application Workflow: Excel to Ou…"]
    F --> G
    G["FAQ"]
    G --> DONE["Key Takeaways"]
    style START fill:#4f46e5,stroke:#4338ca,color:#fff
    style DONE fill:#059669,stroke:#047857,color:#fff

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 [email protected]. 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:

flowchart TD
    ROOT["Building Custom UFO Tasks: Automating Excel,…"] 
    ROOT --> P0["Excel Automation Examples"]
    P0 --> P0C0["Example 1: Data Entry and Formatting"]
    P0 --> P0C1["Example 2: Formula Creation and Charting"]
    P0 --> P0C2["Example 3: Conditional Formatting"]
    ROOT --> P1["Word Automation Examples"]
    P1 --> P1C0["Example 1: Document Creation"]
    P1 --> P1C1["Example 2: Formatting and Styles"]
    ROOT --> P2["FAQ"]
    P2 --> P2C0["Can UFO handle Office 365 web versions …"]
    P2 --> P2C1["How reliable is UFO for production Offi…"]
    P2 --> P2C2["What happens if an Office application c…"]
    style ROOT fill:#4f46e5,stroke:#4338ca,color:#fff
    style P0 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
    style P1 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
    style P2 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
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 [email protected] and CC to [email protected]. "
        "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

Share
C

Written by

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.

Related Articles You May Like

Learn Agentic AI

UFO Action Types: Click, Type, Scroll, and Application-Specific Controls

Comprehensive guide to every action type UFO can perform — from basic clicks and keyboard input to scroll operations, UIA element interactions, and application-specific control manipulation.

Learn Agentic AI

Introduction to Microsoft UFO: AI-Powered Windows Application Automation

Learn what Microsoft UFO is, how its dual-agent architecture combines HostAgent and AppAgent with GPT-4V vision to translate natural language requests into Windows UI actions automatically.

Learn Agentic AI

UFO's Visual Understanding: How GPT-4V Interprets Windows Application Screenshots

Explore how UFO captures, annotates, and sends Windows application screenshots to GPT-4V for UI element detection, control identification, and intelligent action mapping at each automation step.

Learn Agentic AI

Installing and Configuring Microsoft UFO: Getting Started with Windows Automation

Step-by-step guide to installing Microsoft UFO, configuring API keys, setting up the configuration files, and running your first automated Windows task with natural language.

Learn Agentic AI

UFO's Dual-Agent Architecture: How HostAgent and AppAgent Coordinate Tasks

Deep dive into Microsoft UFO's dual-agent system where HostAgent orchestrates application selection and AppAgent executes in-app UI actions, with detailed coordination flow and plan execution examples.

Learn Agentic AI

UFO vs Browser Automation: Desktop Apps That Can't Be Automated with Playwright

Understand when to use Microsoft UFO for Windows desktop automation versus browser tools like Playwright or Selenium, with use cases for legacy apps, native software, and hybrid approaches.