VBA Put a button in the background on a PDF

taisen00

New Member
Joined
Apr 20, 2023
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hello,

following discussion on this post:

The code allows me to add a button with an image. But I would like to be able to use the dynamic fields of the PDF.
Off the button is in the foreground.

VBA Code:
            'Add button with image to this page
            Set pageField = jso.addField("button" & page + 1, "button", page, fieldRect)
            pageField.buttonImportIcon imageFile
            pageField.buttonPosition = jso.Position.iconOnly
            pageField.ReadOnly = True
            pageField.flattenButton

I was thinking of adding : pageField.flattenButton
It does not work. Can someone help me ?

Sorry for my English.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
VBA Code:
'Add button with image to dynamic field
Set pageField = jso.addField("dynamicFieldName", "button", 0, fieldRect)
pageField.buttonImportIcon imageFile
pageField.buttonPosition = jso.Position.iconOnly
pageField.zOrder = 1
pageField.ReadOnly = True
pageField.flattenButton

Replace "dynamicFieldName" with the name of your dynamic field. Setting the "zOrder" property to 1 will ensure that the button is in the foreground.
 
Upvote 0
Hello ChrisFoster,
thank you for your answer.
The code stops at "zOrder".
I don't know why when I said the same thing as in your message..


I'm starting to believe it's not possible.
 
Upvote 0
Hello ChrisFoster,
thank you for your answer.
The code stops at "zOrder".
I don't know why when I said the same thing as in your message..


I'm starting to believe it's not possible.
Hello ChrisFoster,
thank you for your answer.
The code stops at "zOrder".
I don't know why when I said the same thing as in your message..


I'm starting to believe it's not possible.
Are you getting a debug error?
 
Upvote 0
ChrisFoster,

yes, i have getting a debug error.
It says "Runtime error 438: Property or method not handled by this object".
 
Upvote 0
Try

VBA Code:
'Add button with image to this page
Set pageField = jso.addField("button" & page + 1, "button", page, fieldRect)
pageField.buttonImportIcon imageFile
pageField.buttonPosition = jso.Position.iconOnly
pageField.ReadOnly = True

'Check if pageField is a button field and set zOrder to -1
If pageField.type = "button" Then
    pageField.zOrder = -1
End If

'Flatten the button
pageField.flattenButton
 
Upvote 0
Thank you for your answers, it makes me happy.

I still get a 438 error on line:
VBA Code:
pageField.ZOrder = -1

Error 438.png
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top