0

I have what I believe is a systems settings issue. I'm using Excel's VBA to start and run some SAP transactions during the night. Due to company policies my computer screen must be locked when I'm not present.

The code runs some SAP transactions, imports the results to Excel and then uses a subset of the result for running a new SAP transaction. The subset is imported/exported to SAP using Range("A1").CurrentRegion.copy in Excel and then pastes this into SAP SE16N - MBEW table using the Multiple Selection by Field functionality and the SAP built in Upload from Clipboard button/function: session.findById("wnd[1]/tbar[0]/btn[24]").press

I have two computers, logging on with the same user in the same network, both running Windows 10, same SAP GUI version, same office version and with all the settings I can think of checking being verified to be equal. Both computers run the code successfully when the screen is active, but only one succeeds with the paste from clipboard functionality when the screen is locked. All other code is successfully completed by both computers when the screen is locked.

The "failure" does not throw any errors, but it "successfully" pastes nothing instead of what is copied from Excel.
Copy in Excel is working. I checked by pasting this back into Excel. "Task successfully failed"

9
  • It can be also the issue with code.
    – Teamothy
    Nov 21, 2019 at 15:22
  • Most likely not as such. It is the same source file that is used accessed though company OneDrive. As mentioned the code runs OK on both computers when the screen is not locked, but one single command not executing properly when the screen is locked on only one computer. Not a rocket science command either; execute a button click function which is not generally a problem between VBA and SAP with the screen locked. Worth mentioning is that if adding a pause, after the click button function and unlocking the screen, it seems the upload command has been executed, but uploading nothing.
    – Fnk
    Nov 22, 2019 at 8:04
  • Don't really know what is the cause, in general I'm trying to avoid such things like .Select, .Activate, .Copy etc., but I know your case - I was also doing this "trick" in code working with SAP, but no such issue before. Is there any way to change this copy - paste from clipboard into SAP table value = value from your Excel?
    – Teamothy
    Nov 22, 2019 at 8:11
  • Thanks for your input Teamothy. Unfortunately I only have access to the front end user interface so I don't think there is a way around it. If it was a limited dataset I could do a couple of loops, but we're talking 10,000 lines plus input here. Still I'm wondering why it works consistently on one computer, and consistently not on the other when the screen is locked. I've created a loop on the non-working computer causing it to retry the paste until input is captured in SAP. It will then loop through the night until I unlock the screen and then command is successfully completed (???)
    – Fnk
    Nov 25, 2019 at 8:17
  • 1
    I've posted a question in the Microsoft Community on the Excel Clipboard issue. I'm not the first one and some threads has been open for years without MS solving it so I'm not too hopeful. By the way the code worked in Windows 7 for me on the specific computer with problems now. And it seems to be a Windows 10 issue from what I see in the different forums. I'll update if I find a solution.
    – Fnk
    Nov 27, 2019 at 14:19

2 Answers 2

2

In our organisation we had similar issue (with SAP GUI), and just found this workaround on msdn.

Before .copy I added Application.SendKeys command just to wake up locked screen (with "up" button). With waked up locked screen - win10 is able to properly .paste to another application.

1

I don't have an answer, but I may have stumbled upon a workaround.

I had the same issue with Excel-to-SAP clipboard access not working when the Windows 10 desktop is locked. Further testing showed that clipboard errors happened in any cross-application scenario I tried: Notepad-to-Excel, Excel-to-Word...

But I discovered that I don't get the clipboard errors any more if I login to the Windows 10 pc via Remote Desktop Connection instead of the keyboard/console. I can login, schedule the task, disconnect, and it runs fine now.

It breaks again if I unlock the desktop via the keyboard, though, so I guess I'll just never do that again, ever.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.