一、問題描述
在 PowerPoint 2010 不提供另存新檔為 htm、mht 選項,但假如需要將簡報檔案轉換成 htm 或 mht 等網頁格式,該如何處理?
二、方法
可以透過 VBA 撰寫程式呼叫 PowerPoint object model 將簡報檔匯出成 htm 或 mht 檔案,參考以下步驟 :
1. 使用 PowerPoint 2010 開啟 PowerPoint 檔案。
2. 按 Alt + F11 開啟 VBA。
3. 出現 VBA 後,按 Ctrl + G 呼叫 [即時運算] 視窗。
4. 在即時運算中撰寫以下程式碼,其中您必須將 SaveAs後的的內容修改為另存新檔的檔案路徑與名稱,輸入後按 Enter 鍵執行即可另存新檔為 htm。
1 |
ActivePresentation.SaveAs "<Drive>:\users\<username>\desktop\<filename>.htm" , ppSaveAsHTML, msoFalse |
例如要儲存到 C:\ ,檔案名稱為 TEST.htm,則
1 |
ActivePresentation.SaveAs "C:\TEST.htm" , ppSaveAsHTML, msoFalse |
5. 將簡報檔匯出成 htm 檔案結果
6. 若要儲存為 mht,請在即時運算視窗中輸入以下程式碼,其中您必須將 SaveAs後的的內容修改為另存新檔的檔案路徑與名稱
輸入後按 Enter 鍵執行即可另存新檔為 mht。
1 |
ActivePresentation.SaveAs "<Drive>:\users\<username>\desktop\<filename>.htm" , ppSaveAsWebArchive, msoFalse |
例如要儲存到 C:\ ,檔案名稱為 TEST.mht,則
1 |
ActivePresentation.SaveAs "C:\TEST.mht" , ppSaveAsWebArchive, msoFalse |
7. 將簡報檔匯出成 mht 檔案結果。