使用VBA如何调用Adobe Create PDF功能 [英] Using VBA how do I call up the Adobe Create PDF function

查看:2303
本文介绍了使用VBA如何调用Adobe Create PDF功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ExportAsFixedFormat类型:= xlTypePDF,
文件名:= ArchivePath,质量:= xlQualityStandard,
IncludeDocProperties:= True,IgnorePrintAreas _
:= False,OpenAfterPublish:= False

目前这是我所拥有的/ p>

我了解如何导出AsFixedFormat PDF,但我需要知道的是使用VBA访问Acrobat下的创建PDF功能(如下图所示)。如果我做ExportAsFixedFormat链接变平了。 Acrobat创建PDF将允许我使用包含超链接将Excel转换为PDF。





我该怎么做?



我正在使用Excel 2016和Adobe Pro DC




这些是我的adobe引用

解决方案

Acrobat参考应该工作

以下是Adobe的指南

添加后,您可以使用以下代码
提示:它可能会导致您正确编码 - 我不太确定,因为我编码它盲目,因为我的PC中没有Acrobat。

  Sub ExportWithAcrobat()
Dim AcroApp As Acrobat.CAcroApp'I'我不确定它是否需要,因为我们直接创建文档
Dim AcrobatDoc As Acrobat.CAcroPDDoc
Dim numPages As Long
Dim WorkSheetToPDF As Worksheet
Const SaveFilePath =C:\\ \\\\ MergedFile.pdf
设置AcroApp = CreateObject(AcroExch.App)'我不确定它是否需要,因为我们直接创建文档
设置AcrobatDoc = CreateObject(AcroExch .PDDoc)
'起初我们刚刚创建了
numPages = AcrobatDoc.GetNumPages
对于每个WorkSheetToPDF在ActiveWorkbook.Worksheets
如果AcrobatDoc.InsertPages(numPages - 1,WorkSheetToPDF,0,AcrobatDoc.GetNumPages(),True)= False然后,您应该可以使用代码来查看如何在创建的对象中插入所需的工作表1.如果Part1Document.InsertPages( numPag es - 1,ExcelSheet?,0,AcrobatDoc.GetNumPages(),True)= False
MsgBox无法插入页面& numPages
Else'1.如果Part1Document.InsertPages(numPages - 1,ExcelSheet?,0,AcrobatDoc.GetNumPages(),True)= False
numPages = numPages + 1
End If '如果Part1Document.InsertPages(numPages - 1,ExcelSheet?,0,AcrobatDoc.GetNumPages(),True)= False
下一个WorkSheetToPDF
如果AcrobatDoc.Save(PDSaveFull,SaveFilePath)= False然后'2.如果Part1Document.Save(PDSaveFull,C:\temp\MergedFile.pdf)= False
MsgBox无法保存修改的文档
End If'2.如果Part1Document。保存(PDSaveFull,C:\temp\MergedFile.pdf)= False
End Sub

以下页面可能会提供更好的帮助: Link1 Link2


  Sheets("Key Indicators").ExportAsFixedFormat Type:=xlTypePDF,
 Filename:=ArchivePath, Quality:=xlQualityStandard,
 IncludeDocProperties:=True, IgnorePrintAreas _
         :=False, OpenAfterPublish:=False

Currently this is what I have.

I understand how to ExportAsFixedFormat PDF but what I need to know how to do is to access the Create PDF function under Acrobat (As show in the picture below) using VBA. If I do ExportAsFixedFormat the links get flattened. Acrobat "Create PDF" would allow me to convert an Excel to PDF with hyperlinks included.

How would I do that?

I am using Excel 2016 and Adobe Pro DC

These are my adobe references

解决方案

Acrobat Reference should work
Here is the guide from Adobe
Once added, you may use the following code Tip: It may lead you to correct coding -I'm not quite sure since I coded it "blindly" because I don't have Acrobat in my PC-. Debug step by step to see what's doing.

Sub ExportWithAcrobat()
Dim AcroApp As Acrobat.CAcroApp 'I'm not quite sure it's needed since we are creating the doc directly
Dim AcrobatDoc As Acrobat.CAcroPDDoc
Dim numPages As Long
Dim WorkSheetToPDF As Worksheet
Const SaveFilePath = "C:\temp\MergedFile.pdf"
    Set AcroApp = CreateObject("AcroExch.App") 'I'm not quite sure it's needed since we are creating the doc directly
    Set AcrobatDoc = CreateObject("AcroExch.PDDoc")
    'it's going to be 0 at first since we just created
    numPages = AcrobatDoc.GetNumPages
    For Each WorkSheetToPDF In ActiveWorkbook.Worksheets
    If AcrobatDoc.InsertPages(numPages - 1, WorkSheetToPDF, 0, AcrobatDoc.GetNumPages(), True) = False Then 'you should be available to work with the code to see how to insert the sheets that you want in the created object ' 1. If Part1Document.InsertPages(numPages - 1, "ExcelSheet?", 0, AcrobatDoc.GetNumPages(), True) = False
    MsgBox "Cannot insert pages" & numPages
    Else ' 1. If Part1Document.InsertPages(numPages - 1, "ExcelSheet?", 0, AcrobatDoc.GetNumPages(), True) = False
    numPages = numPages + 1
    End If ' 1. If Part1Document.InsertPages(numPages - 1, "ExcelSheet?", 0, AcrobatDoc.GetNumPages(), True) = False
    Next WorkSheetToPDF
    If AcrobatDoc.Save(PDSaveFull, SaveFilePath) = False Then ' 2. If Part1Document.Save(PDSaveFull, "C:\temp\MergedFile.pdf") = False
    MsgBox "Cannot save the modified document"
    End If ' 2. If Part1Document.Save(PDSaveFull, "C:\temp\MergedFile.pdf") = False
End Sub

Following pages may provide better assistance: Link1, Link2

这篇关于使用VBA如何调用Adobe Create PDF功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆