1 votos

¿Cómo insertar un documento de Word (o cvs) o un archivo de vídeo en un documento de Word con AppleScript?

Mientras sigo desarrollando un scriptmás grande (que está funcionando pero para esto), no puedo averiguar cómo insertar un archivo en un documento de Word usando Applescript. Puedo insertar una imagen, pero si el archivo es un documento de Word, una hoja de cálculo de Excel, un archivo de vídeo, etc., no puedo ver en el diccionario dónde están los comandos que lo manejarían. Este ejemplo casi funciona:

on AddAttachmentFileToWordDoc(FilePath, Extension)
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
        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
        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 if VideoFiles contains Extension then
                --this obviously doesn't work, but I would guess that something close to it should.
                make new video at end with properties {file name:FilePath as text, save with document:true}
            else -- everything else, Word docs, excel, etc.
                --make new what?? There is no option for new inline file . . .
            end if
        end tell
    end tell
end tell

end AddAttachmentFileToWordDoc

Como puedes ver sólo he tenido éxito con los archivos gráficos. ¿Alguna idea de cuál debe ser la sintaxis para los otros tipos de archivos? Muchas gracias.

1voto

MBUST Puntos 43

Lo más parecido que he conseguido es añadir, no el archivo, sino un enlace al archivo, así:

tell application "Microsoft Word"
    tell active document
        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
        make new hyperlink object at end with properties {text to display:CommentText, hyperlink address:FilePath, text object:theRange}
    end tell
end tell

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X