My wish is to automate through Excel, where from I will be selecting numbers from a specified column of a worksheet. Those numbers will be decrypted by the program ABC.exe.
The 1st part of the code is to activate command prompt. Then from there I m initiating the program abc.exe. The window title changes from "c:Windowssystem32cmd.exe" to "c:Windowssystem32cmd.exe - abc.exe". But as abc.exe is initiated. Sendkeys is not working.
My code is as follows: (It's supposed to start execution with a button click from a worksheet)
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim WshShell As Object
Dim screen As Object
Dim cvc As Object
Dim strScrBatch As String
Dim strStandard As String
Dim psi As Object
Private Sub CommandButton1_Click()
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "C:WINDOWSsystem32cmd.exe"
Sleep 20
WshShell.SendKeys "cd.."
WshShell.SendKeys "{Enter}"
WshShell.SendKeys "cd XYZ"
WshShell.SendKeys "{Enter}"
Sleep 50
WshShell.SendKeys "ABC.EXE"
WshShell.SendKeys "{Enter}"
strScrBatch = (Range("E" & 2).Value)
strStandard = (Range("E" & 3).Value)
SendKeys strScrBatch, True
WshShell.SendKeys strScrBatch
WshShell.SendKeys "{Enter}"
WshShell.SendKeys strStandard
WshShell.SendKeys "{Enter}"
MsgBox "Task Complete"
End Sub