cancel
Showing results for 
Search instead for 
Did you mean: 

Send Keys on Windows / SAP / saving pdf file

aleksandra-0601
Explorer
0 Kudos

Hello! I need to save the generated pdf from SAP. My code is doing everything until this moment - then SAP is "giving back" the role to Windows and I cannot do anything (via VBA) with this window

aleksandra0601_0-1708006158712.png

 

Can someone help me?

View Entire Topic
aleksandra-0601
Explorer
0 Kudos

Hello @stefan_schnell ,

I tried on different ways, the problem is with the next step, which is confirm the choice. "%(b)" doesn`t work, but also enter doesn`t work. I tried to put it with ENTER and ~, but it doesn`t react. However, react on tab - I can see it with active buttons on the window, and what is more, it reacts with cancel - then it closes the window. But I am not able to open neither save the file

 

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function SetForegroundWindow Lib "user32" ( _
ByVal hwnd As Long) As Long

 

Sub test()


Dim hwnd As Long

 

hwnd = FindWindow(vbNullString, "Descarga de archivos")
SetForegroundWindow hwnd

SendKeys "{tab}"
SendKeys "{tab}"
SendKeys "{tab}"
SendKeys "{ENTER}"

End Sub

 

aleksandra0601_1-1713185427176.png

Unfortunatelly I don`t know Sleep command

stefan_schnell
Active Contributor
0 Kudos

Hello @aleksandra-0601,

let's try another way. Please look at your SAP GUI options an be sure that the option "Show native Microsoft Windows dialogs" is disabled.
If it is not, disable it and try the download again. Perhaps an SAP GUI for Windows dialog will open that you can automate with SAP GUI Scripting. This would eliminate the need to automate the native Windows dialog via FindWindow and SendKeys.

sapguioption.scripting.png

Let us know your results.

Best regards
Stefan