I don’t use Excel so I’m not sure of what is available in the clipboard.
You may try these scripts mainly written by Shane STANLEY.
# clip2tiff
use scripting additions
use framework "Foundation"
use framework "AppKit"
--set beg to current date
set pathToChart to (path to desktop as text) & "theCells.tiff"
my fileFromClipToPath:(POSIX path of pathToChart)
--tell application "SystemUIServer" to display dialog "terminé en " & (current date) - beg
--> "terminé en 28 secondes"
on fileFromClipToPath:thePath
set pb to current application's NSPasteboard's generalPasteboard() -- get pasteboard
# log (pb's types as list)
--> {"com.apple.iWork.TSPNativeMetadata", "com.apple.iWork.TSPNativeData", "com.apple.iWork.TSPDescription", "public.rtf", "NeXT Rich Text Format v1.0 pasteboard type", "public.utf16-external-plain-text", "CorePasteboardFlavorType 0x75743136", "public.utf8-plain-text", "NSStringPboardType", "dyn.ah62d4rv4gk81n65yru", "CorePasteboardFlavorType 0x7573746C", "com.apple.traditional-mac-plain-text", "CorePasteboardFlavorType 0x54455854", "dyn.ah62d4rv4gk81g7d3ru", "CorePasteboardFlavorType 0x7374796C", "com.apple.rtfd", "public.html", "Apple HTML pasteboard type", "public.png", "Apple PNG pasteboard type", "com.adobe.pdf", "Apple PDF pasteboard type", "public.tiff", "NeXT TIFF v4.0 pasteboard type"}
set theData to pb's dataForType:(current application's NSPasteboardTypeTIFF) -- get tiff data off pasteboard
if theData = missing value then error "No tiff data found on clipboard"
set theResult to (theData's writeToFile:thePath atomically:true)
return (theResult = 1)
end fileFromClipToPath:
# clip2pdf
use scripting additions
use framework "Foundation"
use framework "AppKit"
# set beg to current date
set pathToChart to (path to desktop as text) & "theCells.pdf"
my fileFromClipToPath:(POSIX path of pathToChart)
# tell application "SystemUIServer" to display dialog "terminé en " & (current date) - beg
on fileFromClipToPath:thePath
set pb to current application's NSPasteboard's generalPasteboard() -- get pasteboard
# log (pb's types as list)
--> {"com.apple.iWork.TSPNativeMetadata", "com.apple.iWork.TSPNativeData", "com.apple.iWork.TSPDescription", "public.rtf", "NeXT Rich Text Format v1.0 pasteboard type", "public.utf16-external-plain-text", "CorePasteboardFlavorType 0x75743136", "public.utf8-plain-text", "NSStringPboardType", "dyn.ah62d4rv4gk81n65yru", "CorePasteboardFlavorType 0x7573746C", "com.apple.traditional-mac-plain-text", "CorePasteboardFlavorType 0x54455854", "dyn.ah62d4rv4gk81g7d3ru", "CorePasteboardFlavorType 0x7374796C", "com.apple.rtfd", "public.html", "Apple HTML pasteboard type", "public.png", "Apple PNG pasteboard type", "com.adobe.pdf", "Apple PDF pasteboard type", "public.tiff", "NeXT TIFF v4.0 pasteboard type"}
set theData to pb's dataForType:(current application's NSPasteboardTypePDF) -- get pdf data of pasteboard
if theData = missing value then error "No pdf data found on clipboard"
set theResult to (theData's writeToFile:thePath atomically:true)
return (theResult = 1)
end fileFromClipToPath:
The pasteboard’s types reported in the scripts were got from a Numbers document.
Enable the log instruction to get the list of what is available after copying from Excel.
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) jeudi 28 janvier 2016 19:50:10