0

Using WinWrap, trying to open Notepad and paste the Clipboard text inside. I mean, it works on Windows 10 but on Windows 11 it seems like the TaskID returned from Shell command is wrong, so the AppActivate(TaskID) fails.

Notepad opens and I can see the text pasted, but I'm inside an "On Error" statement, so an error message appears to the user. The error description is "Impossible to find the window".

This is the part of the code:

                    Clipboard Msg & vbCrLf
                    TaskID = Shell("Notepad",vbNormalFocus )
                    Debug.Print(TaskID)
                    AppActivate(TaskID)
                    SendKeys("^V"),1    'Control-V

If I take a look to the debug, I can see that the TaskID is different from the notepad PID on the task manager.

Any suggestion?

5
  • Why is the variable $TaskID missing the dollar sign? Commented Mar 12 at 13:59
  • Should it have it? I've used an example from the WWB-COM guide and that does not have the dollar sign Commented Mar 12 at 19:14
  • Seems like I'm not the only one finding this issue: learn.microsoft.com/en-us/answers/questions/2045472/… Commented Mar 12 at 19:28
  • Powershell was removed from the tags. The dollar sign is needed in Powershell cmdlet. The link you provided is showing VBA code which does not need the dollar sign. Commented Mar 12 at 21:31
  • Solved finding the notepad.exe PID with the function in this post: stackoverflow.com/questions/44075292/… Commented Mar 14 at 13:38

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.