Copy Paste inside .exe isn't working only when I start it from inside Excel VBA

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:
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}")
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,214,929
Messages
6,122,314
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top