共用方式為


使用 VBScript 將 Excel 轉換成 PDF

將 Excel 檔案轉換為 PDF:

  1. 使用設定變數動作來建立新的變數,其中包含您要轉換的 Excel 檔案路徑。 在此範例中,變數的名稱為 ExcelFile

    包含 Excel 檔案路徑的 [設定變數] 動作螢幕擷取畫面。

  2. 使用第二個設定變數動作來建立變數,其中包含您要建立的 PDF 檔案路徑。 在此範例中,變數的名稱為 PdfFile

    包含 PDF 檔案路徑的 [設定變數] 動作螢幕擷取畫面。

  3. 部署執行 VBScript動作,並填入以下程式碼。

    Dim Excel
    Dim ExcelDoc
    
    'Opens the Excel file'
    Set Excel = CreateObject("Excel.Application")
    Set ExcelDoc = Excel.Workbooks.open("%ExcelFile%")
    
    'Creates the pdf file'
    Excel.ActiveSheet.ExportAsFixedFormat 0, "%PdfFile%" ,0, 1, 0,,,0
    
    'Closes the Excel file'
    Excel.ActiveWorkbook.Close
    Excel.Application.Quit
    

    [設定執行 VBScript] 動作的螢幕擷取畫面。