2016-03-29 161 views
0

我有一個.xlsx文件,我想用Applescript將它保存爲PDF格式。我已經徹底搜索了這個,但顯然有一百萬個問題。使用Applescript將Excel轉換爲PDF(另存爲PDF)

我想的東西保存爲一個名爲.app,在代碼中...將由代碼塊替換,以活動工作簿轉換爲PDF格式,如:

tell application "Microsoft Excel" 
    activate 
    open "/somedirectory/workbook1.xlsx" 
    ... 
end tell 

回答

-1

找到了!下面是答案:

http://blog.krugazor.eu/2010/01/applescript-batch-saving-to-pdf/

從上面的鏈接列舉了以下:

「基本上,它的作用是模擬鍵盤和點擊允許你做任何事情,用戶將能夠

毫不費力,AppleScript可以使用打印對話框批量保存爲pdf一堆excel文件!「

on open some_items 
    repeat with this_item in some_items 
     try 
      tell application "Microsoft Excel" 
       activate 
       open this_item 
       tell application "System Events" to tell process "Microsoft Excel" 
        --Bring up print window 
        keystroke "p" using command down 
        --Choose "PDF" > "Save as PDF" 
        click (menu button "PDF" of window 1) 
        click (menu item 1 of menu of menu button "PDF" of window 1) 
        delay 2 
        -- Choose the desktop as save locaton (Command-D) 
        keystroke "d" using command down 
        --Save 
        keystroke "s" using command down 
        keystroke return 

        -- wait and close 
        delay 3 
        keystroke "w" using command down 
       end tell 
      end tell 
     end try 
    end repeat 

    tell application "Finder" 
     open desktop 
    end tell 
end open 
+1

對於後代,你能否包括你認爲對你的答案有用的鏈接的相關部分?這樣,如果鏈接發生故障,更改等,您的答案將不會變得無用。非常感謝。 –