2014-06-21 12 views
0

일부 파일은 정품 인 Excel 파일과 일부 Excel 파일 (Excel 파일은 확장명이 .xls 인 파일)이있는 .xls 파일 폴더가 있습니다. . 별도의 프로그램에서 파일을 사용하기 위해 모든 파일을 일관된 형식 (Excel 98-2004)으로 변환하려고 시도하고 원본 파일 이름과 디렉토리 구조를 유지하면서이 작업을 수행하기 위해 AppleScript를 사용하려고합니다. 지금 현재로Applescript : Excel 파일 열기 및 다른 형식으로 저장 (같은 이름 및 경로)

, 나는 파일의 작업 루프 목록을 가지고 있고, 저장 기능을 제외한 모든 것을 달성하고있다 :

set file_Name to "/Users/me/path/to/data.xls" 

tell application "Microsoft Excel" 
    activate 
    open file_Name 
    save workbook as workbook (active workbook) filename file_Name file format (Excel98to2004 file format) with overwrite 
    close workbooks 
    quit 
end tell 

나는이 코드를 실행하면, 다음과 같은 응답 얻을 :

tell application "Microsoft Excel" 
    activate 
    open "/Users/drewmcdonald/Desktop/Madhupur_10February2014.xls" 
    get active workbook 
     --> active workbook 
    save workbook as workbook (active workbook) filename "/Users/drewmcdonald/Desktop/test.xlsx" 
     --> missing value 
    close every workbook 
    quit 
end tell 

스프레드 시트가 성공적으로 열고 닫았지만 파일 형식이 변경되지 않고 '누락 된 값'오류를 어떻게 처리해야할지 모르겠습니다. 이 아이디어를 어떻게 얻는 지 알기 원하십니까? 감사!

EDIT : 파일 형식 매개 변수가 회신 텍스트에서 누락되었습니다. 문제가 있음을 알았습니다.

+0

이것을 해결 했습니까? – mcgrailm

답변

1

알 수 있습니다.

저장하려고하기 전에 get full name of active workbook에 대한 통합 문서 이름 변수를 set으로 지정해야했습니다. Excel에서 시트를 열 때 할당하는 통합 문서 이름이 다소 일치하지 않기 때문입니다. 최종 코드는 다음과 같습니다.

set file_Name to "/Users/me/path/to/data.xls" 

tell application "Microsoft Excel" 
    activate 
    open file_Name 
    set wkbk_name to get full name of active workbook 
    save workbook as workbook wkbk_name filename file_Name file format Excel98to2004 file format with overwrite 
    close workbooks 
    quit 
end tell