Sub PDFSamAutomation(docSrc, pagesDec, repOut)
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 docSrc '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 pagesDec '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 repOut 'Remplir Dossier de sortie
Set oBtn = WaitForUiElem(c, oPane, "Name", "Exécuter", TreeScope_Children, 2)
GetIacc(oBtn).DoDefaultAction 'clic sur le bouton Exécuter
Set oEdit = WaitForUiElem(c, oPane, "Name", "Terminé", TreeScope_Children, 5) ' On attend la fin du traitement
Set oBtn = WaitForUiElem(c, oPDFSam, "Name", "Quitter", TreeScope_Descendants, 2)
GetIacc(oBtn).DoDefaultAction 'clic sur le bouton Quitter
End Sub