Hi all and a happy 2023!
Using Applescript I’m trying to extract data from Microsoft Excel.
A user puts in a unique Job number in a dialog, the script locates the same Job number in column M of an open Excel doc.
Once the unique number has been located in column M it will copy certain cells from the row it belongs to, within the range of column C to column R. Then paste this into a new Microsoft Outlook email along with other text required in the email body.
I only need the data from the columns C, I, M, P and R, but if the entire row in the range C to R is easier I’m happy to manually clear the unwanted cells once it’s in the email body.
I do not want this pasted as plain delimited text, just straight in as an HTML in the “cells” as it is in Excel.
I’ve got as far as the below but with this the user has to filter for the Job number directly in Excel in column M first, then go back to the script dialog to put in the range of cells and the row number it relates, eg C10:R10.
It does return all the data but the result seems to be comma delimited within two braces {{ and I can’t get it into a new email or figure out how I get other text in the email body.
Essentially what I want the email to say in layman’s terms is:
Please find info below regarding this job:
Excel cells pasted here
Thanks and regards
Any help or pointers greatly received
display dialog "Enter Job Number" default answer ""
set theText to text returned of the result
tell application "Microsoft Excel"
set myRange to range theText of sheet "Master Sheet" of workbook "Artwork Tracker V1"
return value of myRange
tell application "Microsoft Outlook"
tell (make new outgoing message with properties {subject:"Enter Subject Details Here", content:myRange})
make new recipient with properties {email address:{name:"Joe Bloggs", address:"Joe.Bloggs@email.co.uk"}}
open
end tell
activate
end tell
end tell