Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on AddAttachmentFileToWordDoc(FilePath, Extension, Filename)
- set GraphicFiles to {"PDF", "jpg", "giff", "TIFF", "gif", "png", "PPM", "PGM", "PNM"}
- set VideoFiles to {"mov", "wmv", "amv", "mp4", "m4p", "mpg", "mpeg", "m4v"}
- tell application "Microsoft Word"
- activate
- tell active document
- --Part 1. Works great. No hidden characters making up a link
- set ContTemp to content of text object
- set StartRange to (count of ContTemp) - 1
- set endrange to StartRange
- set theRange to create range start StartRange end endrange
- -- Part 2. This works almost perfectly, except for the file paths
- tell theRange
- if GraphicFiles contains Extension then
- --this works well
- make new inline picture at end with properties {file name:FilePath as text, save with document:true}
- else -- everything else, Word docs, excel, etc.
- set CommentText to "Click here to open attachment " & Filename
- --This file path gave me trouble
- --set FilePath to "../../../../../../Desktop/EmailStorage/AttachmentStorage/" & Filename
- --This file path works relative to the Word document, though I rather use something like the above
- set FilePath to "AttachmentStorage/" & Filename & " "
- make new hyperlink object at end with properties {text to display:CommentText, hyperlink address:FilePath, text object:theRange}
- end if
- end tell
- end tell
- --Part 3. Does not work well. I can't figure out how to get the range that includes the link
- tell active document
- set EndOfEmail to return & return & " End of Email" & return as string
- set ContTemp to content of text object
- set StartRange to (count of ContTemp) - 1
- set endrange to StartRange
- set theRange to create range start StartRange end endrange
- set style of theRange to style normal
- set content of theRange to EndOfEmail
- end tell
- end tell
Add Comment
Please, Sign In to add comment