Sub PDFSamAutomation()
Dim c As New CUIAutomation, oPDFSam As IUIAutomationElement
Dim oDesktop As IUIAutomationElement, oBtn As IUIAutomationElement
Dim oPane As IUIAutomationElement, oEdit As IUIAutomationElement
Dim oGroup As IUIAutomationElement, oRbtn As IUIAutomationElement
Shell "D:\Logiciels\PdfSam\PdfSam.exe" 'Lancement Logiciel PDFSam
Set oDesktop = c.GetRootElement
Set oPDFSam = WaitForUiElem(c, oDesktop, "AutoId", "JavaFX1", _
TreeScope_Children, 20) ' Recherche de la fenêtre PDFSam TimeOut 20 secondes
Set oBtn = WaitForUiElem2c(c, oPDFSam, "CtrlType", 50000, _
"Name", "Découper", TreeScope_Descendants, 2) 'Bouton Découper
GetIacc(oBtn).DoDefaultAction ' clic sur le bouton
Set oPane = WaitForUiElem(c, oPDFSam, "CtrlType", 50033, TreeScope_Children, 2) 'Premier Panneau
Set oEdit = WaitForUiElem(c, oPane, "CtrlType", 50004, TreeScope_Children, 2)
GetIacc(oEdit).SetValue "D:\temp\output.pdf" 'Remplir Fichier PDF à exploiter
Set oGroup = WaitForUiElem(c, oPane, "Name", "Paramètres de découpage", TreeScope_Children, 2)
Set oRbtn = WaitForUiElem(c, oGroup, "Name", "Après les pages suivantes", TreeScope_Children, 2)
GetIacc(oRbtn).DoDefaultAction ' DefaultAction = cocher
Set oEdit = WaitForUiElem(c, oGroup, "CtrlType", 50004, TreeScope_Children, 2)
GetIacc(oEdit).SetValue "1,2,5" 'Remplir avec pages de séparation
Set oGroup = WaitForUiElem(c, oPane, "Name", "Paramètres de sortie", TreeScope_Children, 2)
Set oEdit = WaitForUiElem(c, oGroup, "CtrlType", 50004, TreeScope_Children, 2)
GetIacc(oEdit).SetValue "D:\temp\pdf" 'Remplir Dossier de sortie
Set oBtn = WaitForUiElem(c, oPane, "Name", "Exécuter", TreeScope_Children, 2)
GetIacc(oBtn).DoDefaultAction 'clic sur le bouton Exécuter
End Sub