Insert an image to pdf using VBA
Copy link to clipboard
Copied
Hey there,
I am using the workaround with the button icon to import an image to a pdf file. And it worked well the last years... But now I got an file read error. I didn't change the code and also the images are the same. And also at the same location. I couldn't find anything on google. Maybe someone else has an idea?
Dim objAcroApp As Object, objAcroAVDoc As Object
Dim objAcroPDDoc As Object, objJSO As Object
Dim varKey As Variant
Dim FDate As String
Set objAcroApp = CreateObject("AcroExch.App")
Set objAcroAVDoc = CreateObject("AcroExch.AVDoc")
' open file
If objAcroAVDoc.Open(templateFile, "") = True Then
Set objAcroPDDoc = objAcroAVDoc.GetPDDoc
Set objJSO = objAcroPDDoc.GetJSObject
ClearForm = objJSO.ResetForm() 'clear the form
'add image
objJSO.getField("##Skizze##").buttonImportIcon ("/C/test.jpg")
End If
Copy link to clipboard
Copied
I found a workaround! I too have a tool that uses the button image hack and it stopped working.
What I did was right before I try to load the image here:
> objJSO.getField("##Skizze##").buttonImportIcon ("/C/test.jpg")
I have it load something empty. So it should look like this:
> objJSO.getField("##Skizze##").buttonImportIcon ("")
> objJSO.getField("##Skizze##").buttonImportIcon ("/C/test.jpg")
Please let me know if this works for you
Copy link to clipboard
Copied
ooft, scratch that it's not working again. For some reason the image doesnt load...
Copy link to clipboard
Copied
It's a pity, but it does not work for me 😞

