2016-09-09 1 views
-1

실행하는 중에 AppleScript에 오류가 있음을 나타내는 데 문제가 있습니다.AppleScript 활성 문서에 저장

가 오류 : "Microsoft Word에서"네가 오류 발견했다. "활성 문서"그렇지 않으면 .. 읽기 "번호 -1728를 활성 문서에서

워드 버전 : 워드 2016 홈 & 사업을 맥

에 대한

코드 :

tell application "Microsoft Word" 
    active 
    open "OSX_El_Capitan:Documents:Header:MyHeader.dotx" 
    set theDoc to active document 
    tell theDoc 
     insert file at text object of bookmark "test" file name "OSX_El_Capitan:Documents:Template:DocTemp" 
     save in "OSX_El_Capitan:Documents:My Save Name.docx" 
    end tell 
end tell 

스크립트는 라인이 중지되었습니다 "...에 저장"이 선을 표시 "에 저장"을 통해 다른 부분이 작동 을 은 어쩌면 문제 활성 문서 여부.. 나도 몰라.

+0

시도'파일 이름으로 저장 "OSX_El_Capitan : 문서 : 내 저장 Name.docx"' – vadian

+0

@vadian 감사합니다. Scripterror : "Microsoft Word"에서 "활성 문서"가 "다른 이름으로 저장"메시지를 이해하지 못한다는 오류가 발생했습니다. 활성 문서의 번호 -1708 – Sh4kr0n

+0

두 구문 모두 작동합니다. 액세스 권한 문제 일 수 있습니다. 하드 디스크의 최상위 레벨에 쓸 수있는 권한이 없으므로 어쨌든 그렇게하지 않는 것이 좋습니다. – vadian

답변

0

@pbell 및 @vadian, 답변 해 주셔서 감사합니다.

문서가 이미 존재하는 경우 스크립트에 오류가 표시되지 않습니다. 이 경우 텍스트는 파일에 기록되지만 저장되지는 ​​않습니다. 그리고 저는 그가 별개의 파일을 열 것이라고 생각합니다.

문서가없는 경우 스크립트에서 오류가 발생합니다.

error "file \":OSX_El_Capitan:Documents:My Save Name\" can not be converted to type alias." number -1700 from file ":OSX_El_Capitan:Documents:My Save Name.docx" to alias 

현재 코드 :

tell application "Microsoft Word" 
    active 
    open "OSX_El_Capitan:Documents:Header:MyHeader.dotx" 
    set theDoc to active document 
    tell theDoc 
    insert file at text object of bookmark "test" file name "OSX_El_Capitan:Documents:Template:DocTemp" 
    set theFile to POSIX file "/Documents/My Save Name.docx" as alias 
    save in theFile 
    end tell 
end tell 
관련 문제