Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3347

Re: VBA Code to export data from SAP and save to Desktop

$
0
0

Hello Mike,

 

this could be a reason.

 

Please, can you try this:

 

WScript.Sleep 10000

Set Wshell = CreateObject("Wscript.Shell")

Do

  WScript.Sleep 100

  bWindowFound = Wshell.AppActivate("Pdf995 Save As")

Loop Until bWindowFound

Wshell.SendKeys ("Parked and Blocked Report" & " " & Format(Date, "mmddyyyy") & ".pdf")

WScript.Sleep 100

Wshell.SendKeys ("{ENTER}")

WScript.Sleep 100


I changed in the loop the duration from 1 second to 0.1 second and the sequence of the commands - Sleep before AppActivate. On this way you reduce your time difference between the activation of the dialog and the sending of the key presses. So has the SAPLPD Print Daemon not much occasion to spark between this activities. Hope it works better now.


Another way would be, if you wait until SAPLPD Print Daemon window is open, via an additional loop, and then you activate your dialog and send the key presses, e.g. like this:


WScript.Sleep 10000

Set Wshell = CreateObject("Wscript.Shell")

Do

  WScript.Sleep 100

  bWindowFound = Wshell.AppActivate("SAPLPD.LOG - SAPLPD")

Loop Until bWindowFound

Do

  WScript.Sleep 100

  bWindowFound = Wshell.AppActivate("Pdf995 Save As")

Loop Until bWindowFound

Wshell.SendKeys ("Parked and Blocked Report" & " " & Format(Date, "mmddyyyy") & ".pdf")

WScript.Sleep 100

Wshell.SendKeys ("{ENTER}")

WScript.Sleep 100


So you are really sure that no other process you know can push in between.


Let us know your results.


Cheers

Stefan



Viewing all articles
Browse latest Browse all 3347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>