Bonjour à tous,
Comme l'indique le titre, Je cherche à enregistrer un PDF à partir d'SAP.
J'ai trouvé quelquechose d'interessant sur un forum anglais:
https://stackoverflow.com/questions/...95476#58095476
Mais je bute sur la toute dernière ligne:
En effet, sur la dernière ligne, j'ai le message "Error occurred when the function was executed".
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 Sub DocumentExtraction() Dim varResponse As Variant 'Prompts the user if macro should be run. varResponse = MsgBox("Are you sure you wish to run extraction macro?", vbYesNo, "Warning!") If varResponse <> vbYes Then Exit Sub Set SapGuiAuto = GetObject("SAPGUI") 'Obtains SAP GUI Scripting object. Set SAPApp = SapGuiAuto.GetScriptingEngine 'Obtains currently running SAP GUI. Set SAPCon = SAPApp.Children(0) 'Obtains the first system currently connected. Set session = SAPCon.Children(0) 'Obtains the first session (window) on that connection. ' SAP scripting starts here. session.findById("wnd[0]").maximize session.findById("wnd[0]/tbar[0]/okcd").Text = "/nFB03" session.findById("wnd[0]").sendVKey 0 session.findById("wnd[0]/usr/txtRF05L-BELNR").Text = "930502016" session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = "7360" session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = "2019" ' These lines are not needed and just recorded by the script recorder of SAP 'session.findById("wnd[0]/usr/txtRF05L-GJAHR").SetFocus 'session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4 session.findById("wnd[0]").sendVKey 0 session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX" session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA" session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0" ' Export of the attached file ' assumption is that it is a PDF file session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").pressToolbarButton "%ATTA_EXPORT" session.findById("wnd[2]/usr/ctxtDY_FILENAME").Text = "930502016.PDF" session.findById("wnd[2]/tbar[0]/btn[11]").press 'message Error occurred when the function was executed End Sub
(Le message d'erreur est dans SAP, une option à cochée?)
Quelqu'un aurait une solution?
Merci par avance au forum :-)
Partager