2016-05-31 17 views
5
Sheets("Key Indicators").ExportAsFixedFormat Type:=xlTypePDF, 
Filename:=ArchivePath, Quality:=xlQualityStandard, 
IncludeDocProperties:=True, IgnorePrintAreas _ 
     :=False, OpenAfterPublish:=False 

Obecnie to jest to, co mam.Korzystanie z VBA, jak mogę wywołać funkcję Adobe Create PDF

Rozumiem, jak wyeksportowaćAsFixedFormat PDF, ale muszę wiedzieć, jak to zrobić, aby uzyskać dostęp do funkcji Utwórz plik PDF w Acrobat (jak pokazano na rysunku poniżej) przy użyciu VBA. Jeśli zrobię ExportAsFixedFormat, linki zostaną spłaszczone. Acrobat "Utwórz PDF" pozwoliłby mi konwertować Excel na PDF z dołączonymi hiperlinkami.

AdobePDFMakerForOffice

Jak to zrobić?

używam Excel 2016 i Adobe Pro DC

enter image description here Są moim adobe odwołuje

+2

Czy dodatek Acrobat zapewnia interfejs API? model obiektowy? * wszystko * programowo dostępne z VBA? Jeśli nie, możesz odwołać się do * SendKeys *, co jest koszmarnym, okropnym sposobem robienia rzeczy. Co jest złego w zapisywaniu jako PDF? Co takiego nie robi dodatek Adobe? –

+0

Jeśli zapisuję jako PDF normalnie, spłaszcza wszystkie linki w dokumencie. –

+1

[This] (http://superuser.com/a/921280/165271) może pomóc –

Odpowiedz

1

Acrobat referencyjny powinien działać
Here is the guide from Adobe
Po dodaniu, można użyć następującego kodu Wskazówka: Może to doprowadzić do poprawienia kodowania - nie jestem całkiem pewien, ponieważ zakodowałem go "na ślepo", ponieważ nie mam Acrobata na moim komputerze. Debuguj krok po kroku, aby zobaczyć, co się dzieje.

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 

Następujące strony może zapewnić lepszą pomoc: Link1, Link2

+0

Pojawia się błąd "Nie można wstawić stron-1" –

+1

Zapoznaj się z dokumentacją i spróbuj "odtworzyć", łącząc je z kodami podanymi na dole, nie można dalej kodować, ponieważ nie mam programu Acrobat. – Sgdva

1
With ActiveSheet 
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:="N:\JKDJKDJ", _ 
    Quality:=xlQualityStandard, IncludeDocProperties:=True, 
    IgnorePrintAreas:=False, OpenAfterPublish:=False 
End With 
+0

Warto zauważyć, że moje linki nie są spłaszczane podczas korzystania z tej metody. – jellz77

+0

Czy są to hiperłącza między arkuszami? –

2
Sub PDF() 
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ 
     "C:\Users\PCNAME\Documents\Book1.pdf", Quality:=xlQualityStandard, _ 
     IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _ 
    True 
End Sub 

Spróbuj powyższe kody

+0

Problem polega na tym, że bez wywoływania Adobe hiperłącza nie przenoszą się do formatu PDF. –

1

Możesz opublikować dowolny zakres Excel jako PDF za pomocą ExportAsFixedFormat. Nie ma potrzeby ustawiania zmiany w programie Acrobat.

' Usage: 
' PublishRangePDF(Thisworkbook, fileName) : Will Publish the entire Workbook 
' PublishRangePDF(AvtiveSheet, fileName) : Will Publish all selected worksheets 
' PublishRangePDF(Range("A1:H100"), fileName) : Will Publish Range("A1:H100") 


Sub PublishRangePDF(RangeObject As Object, fileName As String, Optional OpenAfterPublish As Boolean = False) 
    On Error Resume Next 
    RangeObject.ExportAsFixedFormat Type:=xlTypePDF, fileName:=fileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=OpenAfterPublish 
    On Error GoTo 0 
End Sub 
+0

Problem polega na tym, że bez wywoływania Adobe hiperłącza nie przesyłają się do PDF –

+0

działają dla mnie hiperłącza URL. Linki do zakładek stają się spłaszczone. jellz77 używa ExportAsFixedFormat również powiedziałeś, że nie spłaszcza ich.Jeśli możesz wysłać mi swój skoroszyt, wezmę dużo. Jeśli nie, czy możesz wysłać resztę, jeśli twój kod? –

+0

Hiperłącza do znaczników książek, które chcę zachować. –

Powiązane problemy