用 VBA 创建一个空的 PDF 页面

问题描述 投票:0回答:0

我喜欢创建一个空的 pdf 文件。我有以下代码:


Sub CreateEmptyPDF()
    Dim AcroApp As Object
    Set AcroApp = CreateObject("AcroExch.App")
    
    Dim PDFDoc As Object
    Set PDFDoc = CreateObject("AcroExch.PDDoc")
    
    
    
    ' Create a new PDF document with a single blank page??
    PDFDoc.Create
    PDFDoc.InsertPages PDFDoc.GetNumPages - 1, PDFDoc, 1, 1, 1
    
    ' Save the document to a file
    PDFDoc.Save PDSaveFull, "C:\temp\Empty_page.pdf"
    
    ' Close the document and release resources
    PDFDoc.Close
    AcroApp.Exit

    
End Sub

代码正在创建文件,但是当我打开它时,我有:

此文件无法打开,因为它没有页面。

我玩这个的论点但没有成功

PDFDoc.InsertPages PDFDoc.GetNumPages - 1, PDFDoc, 1, 1, 1
vba acrobat
© www.soinside.com 2019 - 2024. All rights reserved.