H
hopper2506
Mitglied
Thread Starter
- Dabei seit
- 19.04.2018
- Beiträge
- 3
- Reaktionspunkte
- 0
Hallo zusammen,
ich habe leider nicht viel Ahnung vom AppleScript und hoffe, von euch einen Tipp zu bekommen. Ich möchte ein Skript nutzen, dass Word-Dateien per Kontextmenü als PDF speichert. Ein solches habe ich auch gefunden, es funktioniert aber nicht so, wie ich es möchte, da Word 2016 für jeden Dateipfad die Zugriffsermächtigung durch den Benutzer erbittet. Das ist für natürlich extrem lästig, da ich dann genauso gut selber die PDF über Word speichern kann. Meine Idee ist es daher, das Dokument zunächst in einen Ordner zu verschieben, für den ich einmalig den Zugriff gewähre und für den ab dann nicht mehr gefragt wird. Und diese Verschiebung bereitet mir leider Probleme und alle meine Versuche waren leider von keinem Erfolg gekrönt.
Hier zunächst mein Skript:
property thelist : {"doc", "docx"}
on run {input, parameters}
set output to {}
tell application "Microsoft Word" to activate
tell application "Microsoft Word" to set theolddefaultpath to get default file path file path type documents path
repeat with x in input
try
set theDoc to contents of x
tell application "Finder"
set theFilePath to container of theDoc as text
set ext to name extension of theDoc
if ext is in thelist then
set theName to name of theDoc
copy length of theName to l
copy length of ext to xxl
set n to l - exl - 1
copy characters 1 through n of theName as string to theFilename
#Hier soll die Datei kopiert und (im Skript) als theDocTemp benannt werden.
set namepdf to theFilename & ".pdf"
set namedocx to theFilename & ".docx"
set namedoc to theFilename & ".doc"
tell application "Microsoft Word"
set default file path file path type documents path path home_path
open theDocTemp as alias
set theActiveDoc to the active document
save as theActiveDoc file format format PDF file name namepdf
copy (POSIX path of (theFilePath & namepdf as string)) to end of output
close theActiveDoc
end tell
if file namedocx exists then
delete file namedocx
end if
if file namedoc exists then
delete file namedoc
end if
#Hier soll nun die PDF zurück an den Ursprungsort geschoben werden und das temporäre Dokument gelöscht werden.
end if
end tell
end try
end repeat
tell application "Microsoft Word" to set default file path file path type documents path path theolddefaultpath
return output
end run
Könnt ihr mir helfen?
Danke und Gruß,
hopper
ich habe leider nicht viel Ahnung vom AppleScript und hoffe, von euch einen Tipp zu bekommen. Ich möchte ein Skript nutzen, dass Word-Dateien per Kontextmenü als PDF speichert. Ein solches habe ich auch gefunden, es funktioniert aber nicht so, wie ich es möchte, da Word 2016 für jeden Dateipfad die Zugriffsermächtigung durch den Benutzer erbittet. Das ist für natürlich extrem lästig, da ich dann genauso gut selber die PDF über Word speichern kann. Meine Idee ist es daher, das Dokument zunächst in einen Ordner zu verschieben, für den ich einmalig den Zugriff gewähre und für den ab dann nicht mehr gefragt wird. Und diese Verschiebung bereitet mir leider Probleme und alle meine Versuche waren leider von keinem Erfolg gekrönt.
Hier zunächst mein Skript:
property thelist : {"doc", "docx"}
on run {input, parameters}
set output to {}
tell application "Microsoft Word" to activate
tell application "Microsoft Word" to set theolddefaultpath to get default file path file path type documents path
repeat with x in input
try
set theDoc to contents of x
tell application "Finder"
set theFilePath to container of theDoc as text
set ext to name extension of theDoc
if ext is in thelist then
set theName to name of theDoc
copy length of theName to l
copy length of ext to xxl
set n to l - exl - 1
copy characters 1 through n of theName as string to theFilename
#Hier soll die Datei kopiert und (im Skript) als theDocTemp benannt werden.
set namepdf to theFilename & ".pdf"
set namedocx to theFilename & ".docx"
set namedoc to theFilename & ".doc"
tell application "Microsoft Word"
set default file path file path type documents path path home_path
open theDocTemp as alias
set theActiveDoc to the active document
save as theActiveDoc file format format PDF file name namepdf
copy (POSIX path of (theFilePath & namepdf as string)) to end of output
close theActiveDoc
end tell
if file namedocx exists then
delete file namedocx
end if
if file namedoc exists then
delete file namedoc
end if
#Hier soll nun die PDF zurück an den Ursprungsort geschoben werden und das temporäre Dokument gelöscht werden.
end if
end tell
end try
end repeat
tell application "Microsoft Word" to set default file path file path type documents path path theolddefaultpath
return output
end run
Könnt ihr mir helfen?
Danke und Gruß,
hopper