IREALLYambatman
Board Regular
- Joined
- Aug 31, 2016
- Messages
- 63
Hey guys.. So I have a macro that is protected and that I don't have source code access to but that I can run and just want to automate (for work). It pops up a window with a list in it and I just want to select the third item in the list and hit tab and enter. I have worked out everything I need.. the only problem is that my macro just doesn't send the keystrokes after it runs his macro. I was under the impression that using Application.OnTime would be capable of allowing for a second macro to run in the background. But for some reason.. my macro finished first.. seconding those keystrokes nowhere instead of into the macro that I don't have access to.
Code:
Sub QForME(WorkBookName)'Path to File Containing Macro we want to run is C:\x\x.xls
'Name Of Macro we want to run is - QuantMain
Dim wbb As Workbook
On Error Resume Next
Set wbb = Workbooks("x.xls")
On Error GoTo 0
If wbb Is Nothing Then Set wbb = Workbooks.Open("C:\x\x.xls")
Workbooks(WorkBookName).Activate 'We active the file with our original macro as the macro we're about to run will need to work on that file.
Application.OnTime Now + TimeValue("00:00:01"), "x.xls!MAIN"
'Run "Macros.xls!MAIN"
Sleep (1000)
Application.SendKeys ("{Down}{Down}{Down}{Tab}{Enter}")
wbb.Close False
Set wbb = Nothing
End Sub