Hallo,
kann mir jemand heldfen? Ich möchte automatisch über VBA einen Hintergrund in meine PDF Datei einbinden..
Ich habe folgenden Code gefunden und umgeschrieben..:
Funktioniert nur leider nicht :(
Code:
Sub Test_WatermarkPDF2()
Dim base As String
Dim Watermark As String
Dim merged_PDF As String
Watermark = "\\ERPA-SERVER\ERPA-Updates\ERPA-Standards\hintergrund_AiVpack.pdf"
merged_PDF = "\\ERPA-SERVER\ERPA-Updates\ERPA-Standards\display2.pdf"
ApplyBackgroundToPDF merged_PDF, Watermark
End Sub
Private Function ApplyBackgroundToPDF(BasePDF As String, BackgroundPDF As String)
Dim pdDoc As Acrobat.CAcroPDDoc
Dim pdTemplate As Acrobat.CAcroPDDoc
Dim template As Variant
Dim lngPage As Long
'Open base document
Set pdDoc = CreateObject("AcroExch.PDDoc")
pdDoc.Open BasePDF
DoEvents
'Open background document
Set pdTemplate = CreateObject("AcroExch.PDDoc")
pdTemplate.Open BackgroundPDF
DoEvents
'Add background document to base document
pdDoc.InsertPages pdDoc.GetNumPages - 1, pdTemplate, 0, 1, 0
'Create a template from the inserted background document
Set template = pdDoc.GetJSObject.CreateTemplate("background", pdDoc.GetNumPages - 1)
'Place the template as a background to all pages
For lngPage = 0 To pdDoc.GetNumPages - 2
template.Spawn lngPage, True, True
Next
'Delete last page (used for template creation purposes only)
pdDoc.DeletePages pdDoc.GetNumPages - 1, pdDoc.GetNumPages - 1
'Save
pdDoc.Save 1, BasePDF
'Close & Destroy Objects
pdDoc.Close
Set pdDoc = Nothing
pdTemplate.Close
Set pdTemplate = Nothing
End Function
|