Skip to content

Create a Daily Word Report from web and Excel Data

The workflow example uses a number of applications:

  • Web Browser
  • Word
  • Excel

The process steps include:

  1. Data is copied from the Test web page
  2. Word is launched and data is pasted
  3. Data is copied from the web page table
  4. Data is opened in Excel
  5. Data is styled
  6. Data is copied to Word
  7. PDF is created

This is an example of a daily report that can be generated, saved and could be sent as an email.

Scheduler

Using the Windows scheduler the task can be run at a specified time based on when updated data is made available and required.

JavaScript Code

JavaScript code is used to define the invoiceDate object for use in the script

Python Code

In addition to the "native" TagUI code Python script has been included which launches Word and Excel.

Install Python

Use of UI Snapshots

Snapshots of various menu items are used to automate the process.

Note

Using application menu UI images can be unpredictable as depending on the width of an app will depend if the menu item displays as expected or may be hidden as the application resizes.

Try using keyboard shortcuts as this may provide more predictable results

Note

This code is running on the Windows platform

Video: Daily Report Workflow



Daily Report
https://verdapress.uk/services/test-bed/

// READ content from web and paste into Word template
read /html/body/div[3]/main/div/div[3]/article/div[1] to clipvalue


// text to copy from web page and paste to word
clipboard(clipvalue)

// JavaScript
js begin
currentDate = new Date();
cDay = currentDate.getDate();
cMonth = currentDate.getMonth() + 1;
cYear = currentDate.getFullYear();
invoiceDate = cDay+"_"+cMonth+"_"+cYear
js finish

// echo `invoiceDate`

//use Python to launch Word
py begin
import os
os.system('start "word.exe" "C:\\tagui\\vpWorkflow\\vpDailyReport\\daily-report.docx"')
py finish

wait 3
// click
keyboard [ctrl]v

keyboard  [pagedown]
keyboard  [pagedown]
keyboard  [enter]

https://verdapress.uk/services/test-bed/

// READ content from web and paste into Word template

read /html/body/div[3]/main/div/div[3]/article/div[1] to clipvalue


// text to copy from web page and paste to Word
clipboard(clipvalue)

keyboard [ctrl]v

// New page

keyboard [ctrl][enter]

// EXCEL CONTENT HERE

https://verdapress.uk/services/test-bed/

wait 3

// Read content from web table, open in Excel, format and paste into word template

table 1 to table.csv
wait 3

//use Python to launch Excel
py begin
import os
os.system('start "excel.exe" "C:\\tagui\\vpWorkflow\\vpDailyReport\\table.csv"')
py finish

wait 2
keyboard [ctrl]a
keyboard [alt]oca

// Format Excel data

click images/formattable.png
wait 2
keyboard [down]
keyboard [down]
keyboard [enter]

click images/header.png
wait 2
click images/ok.png
wait 2

keyboard [ctrl]c

click images/word.png
wait 2

keyboard [ctrl]v

keyboard [alt] f e a

keyboard C:\\tagui\\vpWorkflow\\vpDailyReport\\report_`invoiceDate`.pdf
keyboard [enter]

To run the script at the terminal type:

tagui daily-report.tag -h

Note

Open the images folder while running the script from the command line so that TagUI can interact with the .png files referenced in the script.

Hint

Download project scripts

Image files may need to be recreated depending on OS and screen resolution


If you require support or help check out our services page.