parkerbelt
Active Member
- Joined
- May 23, 2014
- Messages
- 377
I have the following VBA program that kicks off an .exe.
The .exe was built using AutoIT, which captures mouse clicks and other things.
When I run the .exe outside of the VBA program, everything works perfectly - however, when I run it from within the VBA, everything works except the copy and paste.
I'm thinking that the problem may be as simple as referencing a library, but I'm self taught and new to coding, so I may be wrong.
Here is the vba code:
Here is the AutoIT code:
The .exe was built using AutoIT, which captures mouse clicks and other things.
When I run the .exe outside of the VBA program, everything works perfectly - however, when I run it from within the VBA, everything works except the copy and paste.
I'm thinking that the problem may be as simple as referencing a library, but I'm self taught and new to coding, so I may be wrong.
Here is the vba code:
Code:
Sub Angus()
Dim AngusAppPath As String, varProc As Variant
' On Error Resume Next
AngusAppPath = Chr(34) & "S:\James Jech Stuff\Program 6 - add vba - Copy.exe" & Chr(34) 'Your path here
CreateObject("Wscript.Shell").Run AngusAppPath, 1, True '0=hide window, 1=show window; True = wait on return
'varProc = Shell(AngusAppPath, 1)
Range("A18:P33").Select
Selection.Copy
Range("A35").Select
ActiveSheet.Paste
Rows("37:39").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Rows("38:40").Select
Selection.Delete Shift:=xlUp
Rows("39:41").Select
Selection.Delete Shift:=xlUp
Rows("39:41").Select
Range("G39").Activate
Selection.Delete Shift:=xlUp
Range("A37").Select
ActiveCell.FormulaR1C1 = "=R[-31]C+R[-14]C/2"
Range("A37").Select
Selection.AutoFill Destination:=Range("A37:P37"), Type:=xlFillDefault
Range("A37:P37").Select
Range("A39").Select
ActiveCell.FormulaR1C1 = "=R[-25]C+R[-8]C/2"
Range("A39").Select
Selection.AutoFill Destination:=Range("A39:L39"), Type:=xlFillDefault
Range("A39:L39").Select
Range("N31").Select
End Sub
Here is the AutoIT code:
Code:
Run('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe')
_WinWaitActivate("ChromeDisclaimer.htm - Google Chrome","")
MouseClick("left",351,71,1)
Send("www.angus.org{ENTER}")
_WinWaitActivate("American Angus Association - Google Chrome","")
$myCow = InputBox("Question", "What is your cow's number?")
$myBull = InputBox("Question", "What is your bull's number?")
MouseClick("left",1536,161,1)
;Send("17914484{ENTER}")
;Send($myCow{ENTER})
;Send("$myCow{ENTER}")
Send($myCow & "{ENTER}")
sleep(3000)
_WinWaitActivate("EPD Details - Google Chrome","")
MouseMove(297,747)
MouseDown("left")
MouseMove(1614,982)
MouseUp("left")
sleep(3000)
Send("{CTRLDOWN}c{CTRLUP}")
sleep(3000)
Run('C:\Program Files (x86)\Microsoft Office\Office16\excel.exe')
sleep(3000)
;_WinWaitActivate("Program Manager","")
;MouseClick("left",4297,1053,1)
_WinWaitActivate("Book1 - Excel","")
MouseClick("left",92,285,1)
Send("{CTRLDOWN}v{CTRLUP}")
_WinWaitActivate("Book1 - Excel","")
MouseClick("left",1787,23,1)
_WinWaitActivate("EPD Details - Google Chrome","")
MouseClick("left",1544,165,1)
Send($myBull & "{ENTER}")
sleep(3000)
_WinWaitActivate("EPD Details - Google Chrome","Chrome Legacy Window")
MouseClick("left",1527,160,1)
MouseMove(307,736)
MouseDown("left")
MouseMove(1709,972)
MouseUp("left")
Sleep(3000)
Send("{CTRLDOWN}c{CTRLUP}")
Sleep(3000)
;_WinWaitActivate("Program Manager","")
;MouseClick("left",4230,1052,1)
_WinWaitActivate("Book1 - Excel","")
;_WinWaitActivate("Book1 - Excel","Collect and Paste 2.")
Sleep(3000)
MouseClick("left",88,693,1)
Sleep(3000)
Send("{CTRLDOWN}v{CTRLUP}")