Gelöst Hyperlinks in Pdf
27.05.2021 13:29:14
Oisse
Hallo Zusammen und an denjenigen, den meine Lösung interessiert.
Ich speichere das Tabellenblatt als htm-Dokument ab, denn da funktionieren die internen Links.
Beispielcode, wobei "ThisWorkbook.Path & "\Organisation.htm" der Speicherort und Speichername des htm-Dokuments ist.
"Rednerauflistung" ist der Name des Tabellenblattes aus dem die Daten sind.
"Organisation_1" habe ich jetzt mal so vergeben. Ich habe keine Ahnung, wofür der Parameter gut ist, hatte aber beim Testen keine Auswirkung.
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
ThisWorkbook.Path & "\Organisation.htm", _
"Rednerauflistung", "", xlHtmlStatic, "Organisation_1", "")
.Publish (True)
.AutoRepublish = False
End With
Dann öffne ich dieses htm-Dokument in Word, speichere es als Word-Dokument ab und exportiere es dann als pdf.
Beispielcode, wobei WordName und CDateiName natürlich die frei vergebbaren Dokumenten bzw. Pfadangaben sind.
Dim WordObj As Object
Dim wdDoc As Word.document
Set WordObj = GetObject(, "Word.Application")
If WordObj Is Nothing Then
Set WordObj = CreateObject("Word.Application")
Else
End If
Set wdDoc = WordObj.Documents.Add(ThisWorkbook.Path & "\Organisation.htm")
'wdDoc.Visible = True
Const wdFormatXMLDocument As Integer = 12
wdDoc.SaveAs2 Filename:=ThisWorkbook.Path & "\" & WordName & ".docx", _
FileFormat:=wdFormatXMLDocument
wdDoc.ExportAsFixedFormat outputfilename:=CDateiName, _
exportformat:=17, OpenAfterExport:=True, _
OptimizeFor:=0, Range:=0, Item:=0, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=0, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
WordObj.Save
WordObj.Close
WordObj.Quit