Trying to help an asker elsewhere I wrote :
tell application "Mail"
# grab a selected message
set unMessage to item 1 of (get the selection)
# fill the clipboard with the contents of the message
set the clipboard to (get content of unMessage)
end tell
tell application "Numbers"
set monTableur to make new document
tell monTableur to tell sheet 1 to tell table 1
# As the default table has an header row
# and an header column I remove them.
remove row 1
remove column 1
# Define the point where we will paste
set selection range to range "A1"
end tell
end tell
tell application "System Events" to tell process "Numbers"
set frontmost to true
keystroke "v" using {command down} # Paste the clipboard contents
end tell
set p2d to path to documents folder as text # Edit to fit your needs
set nomDuDoc to "mon tableur.numbers" # Edit to fit your needs
set leChemin to p2d & nomDuDoc as «class furl»
tell application "Numbers"
save monTableur in leChemin # Save the document
end tell
Alas, the asker is unable to convert the code designed for Numbers to a code driving Excel which I never used.
Is someone here fair enough to write the needed instructions ?
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 21 octobre 2019 19:46:18
Given what I found on the net, assuming that a document is already open, I guess that the code dedicated to Excel would be something like:
tell application "Microsoft Excel"
tell sheet "Sheet1" of workbook 1
# Define the target location where we will paste
set theRange to … # ????
# Paste
paste text range theRange
end tell
end tell
I really don’t know how to define theRange.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 21 octobre 2019 21:51:48
tell application "Microsoft Excel"
tell sheet "Sheet1" of active workbook
activate object range "A1"
paste
end tell
end tell
Thank you.
I will pass the info to the original asker.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 22 octobre 2019 16:25:59
Entire script. Like this:
tell application "Mail"
-- grab a selected message
set unMessage to item 1 of (get the selection)
-- fill the clipboard with the contents of the message
set the clipboard to (get content of unMessage)
end tell
set workbookName to "My Workbook.xlsx"
set destinationPath to (path to documents folder as text) & workbookName
tell application "Microsoft Excel"
make new workbook
tell sheet "Sheet1" of active workbook
activate object range "A1"
paste
end tell
save active workbook in destinationPath
end tell
NOTE: You will be asked for grant to Excel access to Documents folder. So, grant it.
Thank you, this time the asker will have all the needed instructions.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 22 octobre 2019 21:37:10